/
maxavangard
/
KTC
Обзор
Документация
Войти
/
maxavangard
/
KTC
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
tests/Unit/LogoutTest.php
64 строки
2 KB
Avangartd
first_commit
28 июн 2026, 18:48
28 июн 2026, 18:48
f36fb03
Код
Авторство
О чём код?
<?php declare(strict_types=1); namespace app\tests\Unit; use app\controllers\SiteController; use app\models\User; use Yii; use yii\base\Security; use yii\web\IdentityInterface; use yii\web\View; final class LogoutTest extends \Codeception\Test\Unit { public function testRenderLogoutLinkWhenUserIsLoggedIn(): void { $user = User::findIdentity('100'); $controller = new SiteController( 'site', Yii::$app, Yii::$app->mailer, new Security(), ); $view = new View(['context' => $controller]); self::assertNotNull( $user, "Failed asserting that the user identity with ID '100' exists.", ); self::assertInstanceOf( IdentityInterface::class, $user, "Failed asserting that the identity is an instance of 'Identity' class.", ); Yii::$app->user->login($user); $html = $view->render('//layouts/main.php', ['content' => 'Hello World°']); self::assertStringContainsString( 'Logout (admin)', $html, 'Failed asserting that the logout link is rendered for a logged-in user.', ); self::assertStringContainsString( 'data-method="post"', $html, 'Failed asserting that the logout link uses POST method.', ); $controller->actionLogout(); $html = $view->render('//layouts/main.php', ['content' => 'Hello World°']); self::assertStringNotContainsString( 'Logout (admin)', $html, 'Failed asserting that the logout link is not rendered after logout.', ); } }