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
php:
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"

View File

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

View File

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

View File

@ -24,18 +24,18 @@ class ContactFormTest extends \Codeception\Test\Unit
'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
$this->tester->seeEmailIsSent();
/** @var MessageInterface $emailMessage */
$emailMessage = $this->tester->grabLastSentEmail();
expect('valid email is sent', $emailMessage)->isInstanceOf('yii\mail\MessageInterface');
expect($emailMessage->getTo())->hasKey('admin@example.com');
expect($emailMessage->getFrom())->hasKey('noreply@example.com');
expect($emailMessage->getReplyTo())->hasKey('tester@example.com');
expect($emailMessage->getSubject())->equals('very important letter subject');
expect($emailMessage->toString())->stringContainsString('body of current message');
verify($emailMessage)->instanceOf('yii\mail\MessageInterface');
verify($emailMessage->getTo())->arrayHasKey('admin@example.com');
verify($emailMessage->getFrom())->arrayHasKey('noreply@example.com');
verify($emailMessage->getReplyTo())->arrayHasKey('tester@example.com');
verify($emailMessage->getSubject())->equals('very important letter subject');
verify($emailMessage->toString())->stringContainsString('body of current message');
}
}

View File

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

View File

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

View File

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