Fix WebTargetRenderTest

This commit is contained in:
buddh4 2019-03-26 19:02:24 +01:00
parent 4f95737334
commit 5869295ea4
3 changed files with 14 additions and 4 deletions

View File

@ -14,7 +14,7 @@ class MailTargetRenderTest extends HumHubDbTestCase
public function testDefaultView()
{
$notification = notifications\TestedMailViewNotification::instance();
$notification = notifications\TestNotification::instance();
$target = Yii::$app->notification->getTarget(MailTarget::class);
$renderer = $target->getRenderer();
$this->assertContains('<h1>TestedMailViewNotificationHTML</h1>', $renderer->render($notification));

View File

@ -2,6 +2,8 @@
namespace humhub\modules\notification\tests\codeception\unit\rendering;
use humhub\modules\post\models\Post;
use humhub\modules\user\models\User;
use Yii;
use tests\codeception\_support\HumHubDbTestCase;
use Codeception\Specify;
@ -14,7 +16,9 @@ class WebTargetRenderTest extends HumHubDbTestCase
public function testDefaultView()
{
$notification = notifications\TestedMailViewNotification::instance();
$notification = notifications\TestNotification::instance()->about(Post::findOne(['id' => 1]));
$notification->send(User::findOne(['id' => 1]));
$target = Yii::$app->notification->getTarget(WebTarget::class);
$renderer = $target->getRenderer();
$result = $renderer->render($notification);
@ -24,8 +28,10 @@ class WebTargetRenderTest extends HumHubDbTestCase
public function testOverwriteViewFile()
{
$notification = notifications\TestedMailViewNotification::instance();
$notification = notifications\TestNotification::instance()->about(Post::findOne(['id' => 1]));
$notification->send(User::findOne(['id' => 1]));
$notification->viewName = 'special';
$notification->saveRecord(User::findOne(['id' => 1]));
$target = Yii::$app->notification->getTarget(WebTarget::class);
$renderer = $target->getRenderer();
$result = $renderer->render($notification);

View File

@ -7,8 +7,12 @@ namespace humhub\modules\notification\tests\codeception\unit\rendering\notificat
*
* @author buddha
*/
class TestedMailViewNotification extends \humhub\modules\notification\components\BaseNotification
class TestNotification extends \humhub\modules\notification\components\BaseNotification
{
public $moduleId = 'notification';
public $requireOriginator = false;
public $requireSource = false;
public function html()
{
return '<h1>TestedMailViewNotificationHTML</h1>';