Skip to content

Commit

Permalink
Shift assertion methods
Browse files Browse the repository at this point in the history
PHPUnit 8 specializes several assertion methods:

- sebastianbergmann/phpunit#3368
- sebastianbergmann/phpunit#3422 (comment)
  • Loading branch information
laravel-shift committed Nov 25, 2023
1 parent 5f223e2 commit 565f10e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions tests/framework/base/CSecurityManagerTest.php
Expand Up @@ -164,7 +164,7 @@ public function testGenerateRandomString()
// student-t test that the distribution of chars is uniform would be nice.
for ($i=1; $i<999; $i+=1){
$ran=$sm->generateRandomString($i,false);
$this->assertInternalType('string', $ran);
$this->assertIsString($ran);
$this->assertEquals(1, preg_match('{[a-zA-Z0-9_~]{' . $i . '}}', $ran));
}
}
Expand All @@ -176,7 +176,7 @@ public function testGenerateRandomBytes()
$mbStrlen = function_exists('mb_strlen');
for ($i=1; $i<255; $i+=1){
$ran=$sm->generateRandomBytes($i,false);
$this->assertInternalType('string', $ran);
$this->assertIsString($ran);
$this->assertEquals($i, $mbStrlen ? mb_strlen($ran, '8bit') : strlen($ran));
}
}
Expand All @@ -191,7 +191,7 @@ public function testGenerateRandomStringCS()
// student-t test that the distribution of chars is uniform would be nice.
for ($i=1; $i<999; $i+=1){
$ran=$sm->generateRandomString($i,true);
$this->assertInternalType('string', $ran);
$this->assertIsString($ran);
$this->assertEquals(1, preg_match('{[a-zA-Z0-9_~]{' . $i . '}}', $ran));
}
}
Expand All @@ -206,7 +206,7 @@ public function testGenerateRandomBytesCS()
$mbStrlen = function_exists('mb_strlen');
for ($i=1; $i<255; $i+=1){
$ran=$sm->generateRandomBytes($i,true);
$this->assertInternalType('string', $ran);
$this->assertIsString($ran);
$this->assertEquals($i, $mbStrlen ? mb_strlen($ran, '8bit') : strlen($ran));
}
}
Expand Down
14 changes: 7 additions & 7 deletions tests/framework/validators/CCompareValidatorTest.php
Expand Up @@ -35,7 +35,7 @@ public function testValidationErrorsWithEquals()
$validator->operator = '=';
$validator->compareAttribute = 'bar';
$script = $validator->clientValidateAttribute($model, 'foo');
$this->assertInternalType('string', $script);
$this->assertIsString($script);
$this->assertContains('Foo must be repeated exactly.', $script);
}

Expand Down Expand Up @@ -65,7 +65,7 @@ public function testValidationErrorsWithNotEquals()
$validator->operator = '!=';
$validator->compareAttribute = 'bar';
$script = $validator->clientValidateAttribute($model, 'foo');
$this->assertInternalType('string', $script);
$this->assertIsString($script);
$this->assertContains('Foo must not be equal to \"{compareValue}\".".replace(\'{compareValue}\', ', $script);

$validator->message = '{compareAttribute}';
Expand Down Expand Up @@ -99,7 +99,7 @@ public function testValidationErrorsWitGreaterThan()
$validator->operator = '>';
$validator->compareAttribute = 'bar';
$script = $validator->clientValidateAttribute($model, 'foo');
$this->assertInternalType('string', $script);
$this->assertIsString($script);
$this->assertContains('Foo must be greater than \"{compareValue}\".".replace(\'{compareValue}\', ', $script);

$validator->message = '{compareAttribute}';
Expand Down Expand Up @@ -133,7 +133,7 @@ public function testValidationErrorsWitGreaterThanOrEqual()
$validator->operator = '>=';
$validator->compareAttribute = 'bar';
$script = $validator->clientValidateAttribute($model, 'foo');
$this->assertInternalType('string', $script);
$this->assertIsString($script);
$this->assertContains('Foo must be greater than or equal to \"{compareValue}\".".replace(\'{compareValue}\', ', $script);

$validator->message = '{compareAttribute}';
Expand Down Expand Up @@ -167,7 +167,7 @@ public function testValidationErrorsWitLessThan()
$validator->operator = '<';
$validator->compareAttribute = 'bar';
$script = $validator->clientValidateAttribute($model, 'foo');
$this->assertInternalType('string', $script);
$this->assertIsString($script);
$this->assertContains('Foo must be less than \"{compareValue}\".".replace(\'{compareValue}\', ', $script);

$validator->message = '{compareAttribute}';
Expand Down Expand Up @@ -201,7 +201,7 @@ public function testValidationErrorsWitLessThanOrEqual()
$validator->operator = '<=';
$validator->compareAttribute = 'bar';
$script = $validator->clientValidateAttribute($model, 'foo');
$this->assertInternalType('string', $script);
$this->assertIsString($script);
$this->assertContains('Foo must be less than or equal to \"{compareValue}\".".replace(\'{compareValue}\', ', $script);

$validator->message = '{compareAttribute}';
Expand Down Expand Up @@ -262,7 +262,7 @@ public function testOverrideCompareValue()
$validator->operator = '=';
$validator->compareValue = 'bar';
$script = $validator->clientValidateAttribute($stub, 'foo');
$this->assertInternalType('string', $script);
$this->assertIsString($script);
$this->assertContains('Foo must be repeated exactly', $script);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/framework/validators/CDateValidatorTest.php
Expand Up @@ -60,7 +60,7 @@ public function testTimestampOption()
$model = $this->getModelMock(['timestampAttribute' => 'bar']);
$model->foo = '01/01/2011';
$this->assertTrue($model->validate());
$this->assertInternalType('integer', $model->bar);
$this->assertIsInteger($model->bar);
$this->assertEquals(strtotime('1 Jan 2011'), $model->bar);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/framework/web/CHttpSessionTest.php
Expand Up @@ -5,7 +5,7 @@ class CHttpSessionTest extends CTestCase {
protected function checkProb($gcProb) {
Yii::app()->session->gCProbability = $gcProb;
$value = Yii::app()->session->gCProbability;
$this->assertInternalType('float', $value);
$this->assertIsFloat($value);
$this->assertLessThanOrEqual(1, $value);
$this->assertGreaterThanOrEqual(0, $value);
$this->assertLessThanOrEqual(1 / 21474836.47, abs($gcProb - $value));
Expand Down

0 comments on commit 565f10e

Please sign in to comment.