Skip to content

Commit

Permalink
Update to PHP 7.4 and codeception/verify 2.2 (yiisoft#260)
Browse files Browse the repository at this point in the history
Co-authored-by: Luke English <[email protected]>
  • Loading branch information
developedsoftware and Luke English authored Feb 25, 2022
1 parent 60d89fc commit 94bfe89
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 124 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ jobs:
- windows-latest

php:
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
Expand Down
19 changes: 11 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'class' => AccessControl::class,
'only' => ['logout'],
'rules' => [
[
Expand All @@ -30,7 +30,7 @@ public function behaviors()
],
],
'verbs' => [
'class' => VerbFilter::className(),
'class' => VerbFilter::class,
'actions' => [
'logout' => ['post'],
],
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/models/ContactFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ public function testEmailIsSentOnContact()
'verifyCode' => 'testme',
];

expect_that($model->contact('[email protected]'));
verify($model->contact('[email protected]'))->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('[email protected]');
expect($emailMessage->getFrom())->hasKey('[email protected]');
expect($emailMessage->getReplyTo())->hasKey('[email protected]');
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('[email protected]');
verify($emailMessage->getFrom())->arrayHasKey('[email protected]');
verify($emailMessage->getReplyTo())->arrayHasKey('[email protected]');
verify($emailMessage->getSubject())->equals('very important letter subject');
verify($emailMessage->toString())->stringContainsString('body of current message');
}
}
16 changes: 8 additions & 8 deletions tests/unit/models/LoginFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function testLoginNoUser()
'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()
Expand All @@ -31,9 +31,9 @@ public function testLoginWrongPassword()
'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()
Expand All @@ -43,9 +43,9 @@ public function testLoginCorrect()
'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');
}

}
24 changes: 12 additions & 12 deletions tests/unit/models/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand All @@ -34,11 +34,11 @@ public function testFindUserByUsername()
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();
}

}
Loading

0 comments on commit 94bfe89

Please sign in to comment.