Update to PHP 7.4 and codeception/verify 2.2 (#260)

Co-authored-by: Luke English <luke.english@ec2i.biz>
This commit is contained in:
Luke English 2022-02-25 14:58:50 +00:00 committed by GitHub
parent 60d89fc552
commit 94bfe89845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 121 additions and 123 deletions

View File

@ -21,11 +21,6 @@ jobs:
- windows-latest - windows-latest
php: php:
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4" - "7.4"
- "8.0" - "8.0"
- "8.1" - "8.1"

View File

@ -14,24 +14,27 @@
}, },
"minimum-stability": "dev", "minimum-stability": "dev",
"require": { "require": {
"php": ">=5.6.0", "php": ">=7.4.0",
"yiisoft/yii2": "~2.0.14", "yiisoft/yii2": "~2.0.14",
"yiisoft/yii2-bootstrap4": "~2.0.0", "yiisoft/yii2-bootstrap4": "~2.0.0",
"yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0" "yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",
"yiisoft/yii2-symfonymailer": "~2.0.3"
}, },
"require-dev": { "require-dev": {
"yiisoft/yii2-debug": "~2.1.0", "yiisoft/yii2-debug": "~2.1.0",
"yiisoft/yii2-gii": "~2.2.0", "yiisoft/yii2-gii": "~2.2.0",
"yiisoft/yii2-faker": "~2.0.0", "yiisoft/yii2-faker": "~2.0.0",
"codeception/codeception": "^4.0", "codeception/codeception": "^4.0",
"codeception/verify": "~0.5.0 || ~1.1.0", "codeception/module-asserts": "^1.0",
"codeception/specify": "~0.4.6", "codeception/module-yii2": "^1.0",
"symfony/browser-kit": ">=2.7 <=4.2.4", "codeception/module-filesystem": "^1.0",
"codeception/module-filesystem": "^1.0.0", "codeception/verify": "^2.2",
"codeception/module-yii2": "^1.0.0", "symfony/browser-kit": ">=2.7 <=4.2.4"
"codeception/module-asserts": "^1.0.0"
}, },
"config": { "config": {
"allow-plugins": {
"yiisoft/yii2-composer" : true
},
"process-timeout": 1800, "process-timeout": 1800,
"fxp-asset": { "fxp-asset": {
"enabled": false "enabled": false

View File

@ -19,7 +19,7 @@ class SiteController extends Controller
{ {
return [ return [
'access' => [ 'access' => [
'class' => AccessControl::className(), 'class' => AccessControl::class,
'only' => ['logout'], 'only' => ['logout'],
'rules' => [ 'rules' => [
[ [
@ -30,7 +30,7 @@ class SiteController extends Controller
], ],
], ],
'verbs' => [ 'verbs' => [
'class' => VerbFilter::className(), 'class' => VerbFilter::class,
'actions' => [ 'actions' => [
'logout' => ['post'], 'logout' => ['post'],
], ],

View File

@ -24,18 +24,18 @@ class ContactFormTest extends \Codeception\Test\Unit
'verifyCode' => 'testme', 'verifyCode' => 'testme',
]; ];
expect_that($model->contact('admin@example.com')); verify($model->contact('admin@example.com'))->notEmpty();
// using Yii2 module actions to check email was sent // using Yii2 module actions to check email was sent
$this->tester->seeEmailIsSent(); $this->tester->seeEmailIsSent();
/** @var MessageInterface $emailMessage */ /** @var MessageInterface $emailMessage */
$emailMessage = $this->tester->grabLastSentEmail(); $emailMessage = $this->tester->grabLastSentEmail();
expect('valid email is sent', $emailMessage)->isInstanceOf('yii\mail\MessageInterface'); verify($emailMessage)->instanceOf('yii\mail\MessageInterface');
expect($emailMessage->getTo())->hasKey('admin@example.com'); verify($emailMessage->getTo())->arrayHasKey('admin@example.com');
expect($emailMessage->getFrom())->hasKey('noreply@example.com'); verify($emailMessage->getFrom())->arrayHasKey('noreply@example.com');
expect($emailMessage->getReplyTo())->hasKey('tester@example.com'); verify($emailMessage->getReplyTo())->arrayHasKey('tester@example.com');
expect($emailMessage->getSubject())->equals('very important letter subject'); verify($emailMessage->getSubject())->equals('very important letter subject');
expect($emailMessage->toString())->stringContainsString('body of current message'); verify($emailMessage->toString())->stringContainsString('body of current message');
} }
} }

View File

@ -20,8 +20,8 @@ class LoginFormTest extends \Codeception\Test\Unit
'password' => 'not_existing_password', 'password' => 'not_existing_password',
]); ]);
expect_not($this->model->login()); verify($this->model->login())->false();
expect_that(\Yii::$app->user->isGuest); verify(\Yii::$app->user->isGuest)->true();
} }
public function testLoginWrongPassword() public function testLoginWrongPassword()
@ -31,9 +31,9 @@ class LoginFormTest extends \Codeception\Test\Unit
'password' => 'wrong_password', 'password' => 'wrong_password',
]); ]);
expect_not($this->model->login()); verify($this->model->login())->false();
expect_that(\Yii::$app->user->isGuest); verify(\Yii::$app->user->isGuest)->true();
expect($this->model->errors)->hasKey('password'); verify($this->model->errors)->arrayHasKey('password');
} }
public function testLoginCorrect() public function testLoginCorrect()
@ -43,9 +43,9 @@ class LoginFormTest extends \Codeception\Test\Unit
'password' => 'demo', 'password' => 'demo',
]); ]);
expect_that($this->model->login()); verify($this->model->login())->true();
expect_not(\Yii::$app->user->isGuest); verify(\Yii::$app->user->isGuest)->false();
expect($this->model->errors)->hasntKey('password'); verify($this->model->errors)->arrayHasNotKey('password');
} }
} }

View File

@ -8,24 +8,24 @@ class UserTest extends \Codeception\Test\Unit
{ {
public function testFindUserById() public function testFindUserById()
{ {
expect_that($user = User::findIdentity(100)); verify($user = User::findIdentity(100))->notEmpty();
expect($user->username)->equals('admin'); verify($user->username)->equals('admin');
expect_not(User::findIdentity(999)); verify(User::findIdentity(999))->empty();
} }
public function testFindUserByAccessToken() public function testFindUserByAccessToken()
{ {
expect_that($user = User::findIdentityByAccessToken('100-token')); verify($user = User::findIdentityByAccessToken('100-token'))->notEmpty();
expect($user->username)->equals('admin'); verify($user->username)->equals('admin');
expect_not(User::findIdentityByAccessToken('non-existing')); verify(User::findIdentityByAccessToken('non-existing'))->empty();
} }
public function testFindUserByUsername() public function testFindUserByUsername()
{ {
expect_that($user = User::findByUsername('admin')); verify($user = User::findByUsername('admin'))->notEmpty();
expect_not(User::findByUsername('not-admin')); verify(User::findByUsername('not-admin'))->empty();
} }
/** /**
@ -34,11 +34,11 @@ class UserTest extends \Codeception\Test\Unit
public function testValidateUser($user) public function testValidateUser($user)
{ {
$user = User::findByUsername('admin'); $user = User::findByUsername('admin');
expect_that($user->validateAuthKey('test100key')); verify($user->validateAuthKey('test100key'))->notEmpty();
expect_not($user->validateAuthKey('test102key')); verify($user->validateAuthKey('test102key'))->empty();
expect_that($user->validatePassword('admin')); verify($user->validatePassword('admin'))->notEmpty();
expect_not($user->validatePassword('123456')); verify($user->validatePassword('123456'))->empty();
} }
} }

View File

@ -15,12 +15,12 @@ class AlertTest extends \Codeception\Test\Unit
$renderingResult = Alert::widget(); $renderingResult = Alert::widget();
expect($renderingResult)->stringContainsString($message); verify($renderingResult)->stringContainsString($message);
expect($renderingResult)->stringContainsString('alert-danger'); verify($renderingResult)->stringContainsString('alert-danger');
expect($renderingResult)->stringNotContainsString('alert-success'); verify($renderingResult)->stringNotContainsString('alert-success');
expect($renderingResult)->stringNotContainsString('alert-info'); verify($renderingResult)->stringNotContainsString('alert-info');
expect($renderingResult)->stringNotContainsString('alert-warning'); verify($renderingResult)->stringNotContainsString('alert-warning');
} }
public function testMultipleErrorMessages() public function testMultipleErrorMessages()
@ -32,13 +32,13 @@ class AlertTest extends \Codeception\Test\Unit
$renderingResult = Alert::widget(); $renderingResult = Alert::widget();
expect($renderingResult)->stringContainsString($firstMessage); verify($renderingResult)->stringContainsString($firstMessage);
expect($renderingResult)->stringContainsString($secondMessage); verify($renderingResult)->stringContainsString($secondMessage);
expect($renderingResult)->stringContainsString('alert-danger'); verify($renderingResult)->stringContainsString('alert-danger');
expect($renderingResult)->stringNotContainsString('alert-success'); verify($renderingResult)->stringNotContainsString('alert-success');
expect($renderingResult)->stringNotContainsString('alert-info'); verify($renderingResult)->stringNotContainsString('alert-info');
expect($renderingResult)->stringNotContainsString('alert-warning'); verify($renderingResult)->stringNotContainsString('alert-warning');
} }
public function testSingleDangerMessage() public function testSingleDangerMessage()
@ -49,12 +49,12 @@ class AlertTest extends \Codeception\Test\Unit
$renderingResult = Alert::widget(); $renderingResult = Alert::widget();
expect($renderingResult)->stringContainsString($message); verify($renderingResult)->stringContainsString($message);
expect($renderingResult)->stringContainsString('alert-danger'); verify($renderingResult)->stringContainsString('alert-danger');
expect($renderingResult)->stringNotContainsString('alert-success'); verify($renderingResult)->stringNotContainsString('alert-success');
expect($renderingResult)->stringNotContainsString('alert-info'); verify($renderingResult)->stringNotContainsString('alert-info');
expect($renderingResult)->stringNotContainsString('alert-warning'); verify($renderingResult)->stringNotContainsString('alert-warning');
} }
public function testMultipleDangerMessages() public function testMultipleDangerMessages()
@ -66,13 +66,13 @@ class AlertTest extends \Codeception\Test\Unit
$renderingResult = Alert::widget(); $renderingResult = Alert::widget();
expect($renderingResult)->stringContainsString($firstMessage); verify($renderingResult)->stringContainsString($firstMessage);
expect($renderingResult)->stringContainsString($secondMessage); verify($renderingResult)->stringContainsString($secondMessage);
expect($renderingResult)->stringContainsString('alert-danger'); verify($renderingResult)->stringContainsString('alert-danger');
expect($renderingResult)->stringNotContainsString('alert-success'); verify($renderingResult)->stringNotContainsString('alert-success');
expect($renderingResult)->stringNotContainsString('alert-info'); verify($renderingResult)->stringNotContainsString('alert-info');
expect($renderingResult)->stringNotContainsString('alert-warning'); verify($renderingResult)->stringNotContainsString('alert-warning');
} }
public function testSingleSuccessMessage() public function testSingleSuccessMessage()
@ -83,12 +83,12 @@ class AlertTest extends \Codeception\Test\Unit
$renderingResult = Alert::widget(); $renderingResult = Alert::widget();
expect($renderingResult)->stringContainsString($message); verify($renderingResult)->stringContainsString($message);
expect($renderingResult)->stringContainsString('alert-success'); verify($renderingResult)->stringContainsString('alert-success');
expect($renderingResult)->stringNotContainsString('alert-danger'); verify($renderingResult)->stringNotContainsString('alert-danger');
expect($renderingResult)->stringNotContainsString('alert-info'); verify($renderingResult)->stringNotContainsString('alert-info');
expect($renderingResult)->stringNotContainsString('alert-warning'); verify($renderingResult)->stringNotContainsString('alert-warning');
} }
public function testMultipleSuccessMessages() public function testMultipleSuccessMessages()
@ -100,13 +100,13 @@ class AlertTest extends \Codeception\Test\Unit
$renderingResult = Alert::widget(); $renderingResult = Alert::widget();
expect($renderingResult)->stringContainsString($firstMessage); verify($renderingResult)->stringContainsString($firstMessage);
expect($renderingResult)->stringContainsString($secondMessage); verify($renderingResult)->stringContainsString($secondMessage);
expect($renderingResult)->stringContainsString('alert-success'); verify($renderingResult)->stringContainsString('alert-success');
expect($renderingResult)->stringNotContainsString('alert-danger'); verify($renderingResult)->stringNotContainsString('alert-danger');
expect($renderingResult)->stringNotContainsString('alert-info'); verify($renderingResult)->stringNotContainsString('alert-info');
expect($renderingResult)->stringNotContainsString('alert-warning'); verify($renderingResult)->stringNotContainsString('alert-warning');
} }
public function testSingleInfoMessage() public function testSingleInfoMessage()
@ -117,12 +117,12 @@ class AlertTest extends \Codeception\Test\Unit
$renderingResult = Alert::widget(); $renderingResult = Alert::widget();
expect($renderingResult)->stringContainsString($message); verify($renderingResult)->stringContainsString($message);
expect($renderingResult)->stringContainsString('alert-info'); verify($renderingResult)->stringContainsString('alert-info');
expect($renderingResult)->stringNotContainsString('alert-danger'); verify($renderingResult)->stringNotContainsString('alert-danger');
expect($renderingResult)->stringNotContainsString('alert-success'); verify($renderingResult)->stringNotContainsString('alert-success');
expect($renderingResult)->stringNotContainsString('alert-warning'); verify($renderingResult)->stringNotContainsString('alert-warning');
} }
public function testMultipleInfoMessages() public function testMultipleInfoMessages()
@ -134,13 +134,13 @@ class AlertTest extends \Codeception\Test\Unit
$renderingResult = Alert::widget(); $renderingResult = Alert::widget();
expect($renderingResult)->stringContainsString($firstMessage); verify($renderingResult)->stringContainsString($firstMessage);
expect($renderingResult)->stringContainsString($secondMessage); verify($renderingResult)->stringContainsString($secondMessage);
expect($renderingResult)->stringContainsString('alert-info'); verify($renderingResult)->stringContainsString('alert-info');
expect($renderingResult)->stringNotContainsString('alert-danger'); verify($renderingResult)->stringNotContainsString('alert-danger');
expect($renderingResult)->stringNotContainsString('alert-success'); verify($renderingResult)->stringNotContainsString('alert-success');
expect($renderingResult)->stringNotContainsString('alert-warning'); verify($renderingResult)->stringNotContainsString('alert-warning');
} }
public function testSingleWarningMessage() public function testSingleWarningMessage()
@ -151,12 +151,12 @@ class AlertTest extends \Codeception\Test\Unit
$renderingResult = Alert::widget(); $renderingResult = Alert::widget();
expect($renderingResult)->stringContainsString($message); verify($renderingResult)->stringContainsString($message);
expect($renderingResult)->stringContainsString('alert-warning'); verify($renderingResult)->stringContainsString('alert-warning');
expect($renderingResult)->stringNotContainsString('alert-danger'); verify($renderingResult)->stringNotContainsString('alert-danger');
expect($renderingResult)->stringNotContainsString('alert-success'); verify($renderingResult)->stringNotContainsString('alert-success');
expect($renderingResult)->stringNotContainsString('alert-info'); verify($renderingResult)->stringNotContainsString('alert-info');
} }
public function testMultipleWarningMessages() public function testMultipleWarningMessages()
@ -168,13 +168,13 @@ class AlertTest extends \Codeception\Test\Unit
$renderingResult = Alert::widget(); $renderingResult = Alert::widget();
expect($renderingResult)->stringContainsString($firstMessage); verify($renderingResult)->stringContainsString($firstMessage);
expect($renderingResult)->stringContainsString($secondMessage); verify($renderingResult)->stringContainsString($secondMessage);
expect($renderingResult)->stringContainsString('alert-warning'); verify($renderingResult)->stringContainsString('alert-warning');
expect($renderingResult)->stringNotContainsString('alert-danger'); verify($renderingResult)->stringNotContainsString('alert-danger');
expect($renderingResult)->stringNotContainsString('alert-success'); verify($renderingResult)->stringNotContainsString('alert-success');
expect($renderingResult)->stringNotContainsString('alert-info'); verify($renderingResult)->stringNotContainsString('alert-info');
} }
public function testSingleMixedMessages() { public function testSingleMixedMessages() {
@ -192,16 +192,16 @@ class AlertTest extends \Codeception\Test\Unit
$renderingResult = Alert::widget(); $renderingResult = Alert::widget();
expect($renderingResult)->stringContainsString($errorMessage); verify($renderingResult)->stringContainsString($errorMessage);
expect($renderingResult)->stringContainsString($dangerMessage); verify($renderingResult)->stringContainsString($dangerMessage);
expect($renderingResult)->stringContainsString($successMessage); verify($renderingResult)->stringContainsString($successMessage);
expect($renderingResult)->stringContainsString($infoMessage); verify($renderingResult)->stringContainsString($infoMessage);
expect($renderingResult)->stringContainsString($warningMessage); verify($renderingResult)->stringContainsString($warningMessage);
expect($renderingResult)->stringContainsString('alert-danger'); verify($renderingResult)->stringContainsString('alert-danger');
expect($renderingResult)->stringContainsString('alert-success'); verify($renderingResult)->stringContainsString('alert-success');
expect($renderingResult)->stringContainsString('alert-info'); verify($renderingResult)->stringContainsString('alert-info');
expect($renderingResult)->stringContainsString('alert-warning'); verify($renderingResult)->stringContainsString('alert-warning');
} }
public function testMultipleMixedMessages() { public function testMultipleMixedMessages() {
@ -224,21 +224,21 @@ class AlertTest extends \Codeception\Test\Unit
$renderingResult = Alert::widget(); $renderingResult = Alert::widget();
expect($renderingResult)->stringContainsString($firstErrorMessage); verify($renderingResult)->stringContainsString($firstErrorMessage);
expect($renderingResult)->stringContainsString($secondErrorMessage); verify($renderingResult)->stringContainsString($secondErrorMessage);
expect($renderingResult)->stringContainsString($firstDangerMessage); verify($renderingResult)->stringContainsString($firstDangerMessage);
expect($renderingResult)->stringContainsString($secondDangerMessage); verify($renderingResult)->stringContainsString($secondDangerMessage);
expect($renderingResult)->stringContainsString($firstSuccessMessage); verify($renderingResult)->stringContainsString($firstSuccessMessage);
expect($renderingResult)->stringContainsString($secondSuccessMessage); verify($renderingResult)->stringContainsString($secondSuccessMessage);
expect($renderingResult)->stringContainsString($firstInfoMessage); verify($renderingResult)->stringContainsString($firstInfoMessage);
expect($renderingResult)->stringContainsString($secondInfoMessage); verify($renderingResult)->stringContainsString($secondInfoMessage);
expect($renderingResult)->stringContainsString($firstWarningMessage); verify($renderingResult)->stringContainsString($firstWarningMessage);
expect($renderingResult)->stringContainsString($secondWarningMessage); verify($renderingResult)->stringContainsString($secondWarningMessage);
expect($renderingResult)->stringContainsString('alert-danger'); verify($renderingResult)->stringContainsString('alert-danger');
expect($renderingResult)->stringContainsString('alert-success'); verify($renderingResult)->stringContainsString('alert-success');
expect($renderingResult)->stringContainsString('alert-info'); verify($renderingResult)->stringContainsString('alert-info');
expect($renderingResult)->stringContainsString('alert-warning'); verify($renderingResult)->stringContainsString('alert-warning');
} }
public function testFlashIntegrity() public function testFlashIntegrity()
@ -255,7 +255,7 @@ class AlertTest extends \Codeception\Test\Unit
Yii::$app->session->close(); Yii::$app->session->close();
Yii::$app->session->open(); Yii::$app->session->open();
expect(Yii::$app->session->getFlash('error'))->null(); verify(Yii::$app->session->getFlash('error'))->empty();
expect(Yii::$app->session->getFlash('unrelated'))->equals($unrelatedMessage); verify(Yii::$app->session->getFlash('unrelated'))->equals($unrelatedMessage);
} }
} }

View File

@ -51,7 +51,7 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $form->field($model, 'body')->textarea(['rows' => 6]) ?> <?= $form->field($model, 'body')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [ <?= $form->field($model, 'verifyCode')->widget(Captcha::class, [
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
]) ?> ]) ?>