mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 13:02:24 +08:00
Raise version min PHP 7.3.
This commit is contained in:
@ -19,7 +19,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class ActionFilterTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
|
||||
@ -20,14 +20,14 @@ class BaseObjectTest extends TestCase
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
$this->object = new NewObject();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
$this->object = null;
|
||||
@ -159,19 +159,6 @@ class BaseObjectTest extends TestCase
|
||||
$this->expectExceptionMessage('Getting write-only property: yiiunit\framework\base\NewObject::writeOnly');
|
||||
$this->object->writeOnly;
|
||||
}
|
||||
|
||||
public function testBackwardCompatibilityWithObject()
|
||||
{
|
||||
if (PHP_MAJOR_VERSION > 7 || (PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION >= 2)) {
|
||||
$this->markTestSkipped('This test is meant to run on PHP <7.2.0 to check BC with yii\base\Object');
|
||||
}
|
||||
$this->assertInstanceOf('yii\base\Object', new BCObject());
|
||||
$this->assertInstanceOf('yii\base\BaseObject', new BCObject());
|
||||
|
||||
BCObject::$initCalled = false;
|
||||
new BCObject();
|
||||
$this->assertTrue(BCObject::$initCalled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -73,13 +73,13 @@ class BarBehavior extends Behavior
|
||||
*/
|
||||
class BehaviorTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
gc_enable();
|
||||
|
||||
@ -33,14 +33,14 @@ class ComponentTest extends TestCase
|
||||
*/
|
||||
protected $component;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
$this->component = new NewComponent();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
$this->component = null;
|
||||
@ -451,11 +451,6 @@ class ComponentTest extends TestCase
|
||||
*/
|
||||
public function testEventClosureDetachesItself()
|
||||
{
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->markTestSkipped('Can not be tested on PHP < 7.0');
|
||||
return;
|
||||
}
|
||||
|
||||
$obj = require __DIR__ . '/stub/AnonymousComponentClass.php';
|
||||
|
||||
$obj->trigger('barEventOnce');
|
||||
|
||||
@ -15,7 +15,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class DynamicModelTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
|
||||
@ -18,13 +18,13 @@ class EventTest extends TestCase
|
||||
{
|
||||
public $counter;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->counter = 0;
|
||||
Event::offAll();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
Event::offAll();
|
||||
|
||||
@ -20,7 +20,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class ModelTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
@ -502,11 +502,6 @@ class ModelTest extends TestCase
|
||||
|
||||
public function testFormNameWithAnonymousClass()
|
||||
{
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->markTestSkipped('Can not be tested on PHP < 7.0');
|
||||
return;
|
||||
}
|
||||
|
||||
$model = require __DIR__ . '/stub/AnonymousModelClass.php';
|
||||
|
||||
$this->expectException('yii\base\InvalidConfigException');
|
||||
|
||||
@ -18,7 +18,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class ModuleTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
|
||||
@ -22,7 +22,7 @@ class SecurityTest extends TestCase
|
||||
*/
|
||||
protected $security;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->security = new ExposedSecurity();
|
||||
@ -813,12 +813,14 @@ TEXT;
|
||||
|
||||
/**
|
||||
* @dataProvider randomKeyInvalidInputs
|
||||
* @expectedException \yii\base\InvalidParamException
|
||||
* @param mixed $input
|
||||
*
|
||||
* @param int|string|array $input
|
||||
*/
|
||||
public function testRandomKeyInvalidInput($input)
|
||||
{
|
||||
$key1 = $this->security->generateRandomKey($input);
|
||||
$this->expectException(\yii\base\InvalidArgumentException::class);
|
||||
|
||||
$this->security->generateRandomKey($input);
|
||||
}
|
||||
|
||||
public function testGenerateRandomKey()
|
||||
@ -826,10 +828,10 @@ TEXT;
|
||||
// test various string lengths
|
||||
for ($length = 1; $length < 64; $length++) {
|
||||
$key1 = $this->security->generateRandomKey($length);
|
||||
$this->assertInternalType('string', $key1);
|
||||
$this->assertIsString($key1);
|
||||
$this->assertEquals($length, strlen($key1));
|
||||
$key2 = $this->security->generateRandomKey($length);
|
||||
$this->assertInternalType('string', $key2);
|
||||
$this->assertIsString($key2);
|
||||
$this->assertEquals($length, strlen($key2));
|
||||
if ($length >= 7) { // avoid random test failure, short strings are likely to collide
|
||||
$this->assertNotEquals($key1, $key2);
|
||||
@ -839,10 +841,10 @@ TEXT;
|
||||
// test for /dev/urandom, reading larger data to see if loop works properly
|
||||
$length = 1024 * 1024;
|
||||
$key1 = $this->security->generateRandomKey($length);
|
||||
$this->assertInternalType('string', $key1);
|
||||
$this->assertIsString($key1);
|
||||
$this->assertEquals($length, strlen($key1));
|
||||
$key2 = $this->security->generateRandomKey($length);
|
||||
$this->assertInternalType('string', $key2);
|
||||
$this->assertIsString($key2);
|
||||
$this->assertEquals($length, strlen($key2));
|
||||
$this->assertNotEquals($key1, $key2);
|
||||
}
|
||||
@ -1103,11 +1105,11 @@ TEXT;
|
||||
$this->assertEquals('', $this->security->unmaskToken('1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \yii\base\InvalidParamException
|
||||
*/
|
||||
public function testMaskingInvalidStrings()
|
||||
{
|
||||
$this->expectException(\yii\base\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('First parameter ($length) must be greater than 0');
|
||||
|
||||
$this->security->maskToken('');
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class ThemeTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$config = ['aliases' => ['@web' => '']];
|
||||
$this->mockWebApplication($config);
|
||||
|
||||
@ -24,7 +24,7 @@ class ViewTest extends TestCase
|
||||
*/
|
||||
protected $testViewPath = '';
|
||||
|
||||
public function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@ -33,7 +33,7 @@ class ViewTest extends TestCase
|
||||
FileHelper::createDirectory($this->testViewPath);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
FileHelper::removeDirectory($this->testViewPath);
|
||||
parent::tearDown();
|
||||
|
||||
@ -21,7 +21,7 @@ class WidgetTest extends TestCase
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
Widget::$counter = 0;
|
||||
|
||||
Reference in New Issue
Block a user