Raise version min PHP 7.3.

This commit is contained in:
Wilmer Arambula
2024-03-20 17:27:20 -03:00
parent e2a167028b
commit ce813e5060
189 changed files with 1901 additions and 1586 deletions

View File

@ -32,7 +32,7 @@ class AssetControllerTest extends TestCase
*/
protected $testAssetsBasePath = '';
public function setUp()
protected function setUp(): void
{
$this->mockApplication();
$this->testFilePath = Yii::getAlias('@yiiunit/runtime') . DIRECTORY_SEPARATOR . str_replace('\\', '_', get_class($this)) . uniqid();
@ -41,7 +41,7 @@ class AssetControllerTest extends TestCase
$this->createDir($this->testAssetsBasePath);
}
public function tearDown()
protected function tearDown(): void
{
$this->removeDir($this->testFilePath);
}
@ -258,7 +258,7 @@ EOL;
$this->runAssetControllerAction('template', [$configFileName]);
$this->assertFileExists($configFileName, 'Unable to create config file template!');
$config = require $configFileName;
$this->assertInternalType('array', $config, 'Invalid config created!');
$this->assertIsArray($config, 'Invalid config created!');
}
public function testActionCompress()
@ -304,7 +304,7 @@ EOL;
// Then :
$this->assertFileExists($bundleFile, 'Unable to create output bundle file!');
$compressedBundleConfig = require $bundleFile;
$this->assertInternalType('array', $compressedBundleConfig, 'Output bundle file has incorrect format!');
$this->assertIsArray($compressedBundleConfig, 'Output bundle file has incorrect format!');
$this->assertCount(2, $compressedBundleConfig, 'Output bundle config contains wrong bundle count!');
$this->assertArrayHasKey($assetBundleClassName, $compressedBundleConfig, 'Source bundle is lost!');
@ -320,11 +320,19 @@ EOL;
$compressedCssFileContent = file_get_contents($compressedCssFileName);
foreach ($cssFiles as $name => $content) {
$this->assertContains($content, $compressedCssFileContent, "Source of '{$name}' is missing in combined file!");
$this->assertStringContainsString(
$content,
$compressedCssFileContent,
"Source of '{$name}' is missing in combined file!",
);
}
$compressedJsFileContent = file_get_contents($compressedJsFileName);
foreach ($jsFiles as $name => $content) {
$this->assertContains($content, $compressedJsFileContent, "Source of '{$name}' is missing in combined file!");
$this->assertStringContainsString(
$content,
$compressedJsFileContent,
"Source of '{$name}' is missing in combined file!",
);
}
}
@ -384,7 +392,7 @@ EOL;
// Then :
$this->assertFileExists($bundleFile, 'Unable to create output bundle file!');
$compressedBundleConfig = require $bundleFile;
$this->assertInternalType('array', $compressedBundleConfig, 'Output bundle file has incorrect format!');
$this->assertIsArray($compressedBundleConfig, 'Output bundle file has incorrect format!');
$this->assertArrayHasKey($externalAssetBundleClassName, $compressedBundleConfig, 'External bundle is lost!');
$compressedExternalAssetConfig = $compressedBundleConfig[$externalAssetBundleClassName];
@ -392,7 +400,11 @@ EOL;
$this->assertEquals($externalAssetConfig['css'], $compressedExternalAssetConfig['css'], 'External bundle css is lost!');
$compressedRegularAssetConfig = $compressedBundleConfig[$regularAssetBundleClassName];
$this->assertContains($externalAssetBundleClassName, $compressedRegularAssetConfig['depends'], 'Dependency on external bundle is lost!');
$this->assertContains(
$externalAssetBundleClassName,
$compressedRegularAssetConfig['depends'],
'Dependency on external bundle is lost!',
);
}
/**

View File

@ -23,7 +23,7 @@ abstract class BaseMessageControllerTest extends TestCase
protected $configFileName = '';
protected $language = 'en';
public function setUp()
protected function setUp(): void
{
$this->mockApplication();
$this->sourcePath = Yii::getAlias('@yiiunit/runtime/test_source');
@ -47,7 +47,7 @@ abstract class BaseMessageControllerTest extends TestCase
return $this->configFileName;
}
public function tearDown()
protected function tearDown(): void
{
FileHelper::removeDirectory($this->sourcePath);
if (file_exists($this->configFileName)) {

View File

@ -29,7 +29,7 @@ class CacheControllerTest extends TestCase
private $driverName = 'mysql';
protected function setUp()
protected function setUp(): void
{
parent::setUp();
@ -137,11 +137,11 @@ class CacheControllerTest extends TestCase
$this->assertEquals('firstValue', Yii::$app->firstCache->get('firstKey'), 'first cache data should not be flushed');
}
/**
* @expectedException \yii\console\Exception
*/
public function testNothingToFlushException()
{
$this->expectException('yii\console\Exception');
$this->expectExceptionMessage('You should specify cache components names');
$this->_cacheController->actionFlush();
}

View File

@ -51,7 +51,7 @@ class DbMessageControllerTest extends BaseMessageControllerTest
}
}
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
$databases = static::getParam('databases');
@ -65,7 +65,7 @@ class DbMessageControllerTest extends BaseMessageControllerTest
static::runConsoleAction('migrate/up', ['migrationPath' => '@yii/i18n/migrations/', 'interactive' => false]);
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
static::runConsoleAction('migrate/down', ['migrationPath' => '@yii/i18n/migrations/', 'interactive' => false]);
if (static::$db) {
@ -75,7 +75,7 @@ class DbMessageControllerTest extends BaseMessageControllerTest
parent::tearDownAfterClass();
}
public function tearDown()
protected function tearDown(): void
{
parent::tearDown();
Yii::$app = null;

View File

@ -30,7 +30,7 @@ class FixtureControllerTest extends DatabaseTestCase
protected $driverName = 'mysql';
protected function setUp()
protected function setUp(): void
{
parent::setUp();
@ -46,7 +46,7 @@ class FixtureControllerTest extends DatabaseTestCase
], [null, null]); //id and module are null
}
protected function tearDown()
protected function tearDown(): void
{
$this->_fixtureController = null;
FixtureStorage::clear();

View File

@ -21,7 +21,7 @@ class HelpControllerTest extends TestCase
/**
* {@inheritdoc}
*/
public function setUp()
protected function setUp(): void
{
$this->mockApplication();
}
@ -154,37 +154,37 @@ STRING
public function testActionIndex()
{
$result = Console::stripAnsiFormat($this->runControllerAction('index'));
$this->assertContains('This is Yii version ', $result);
$this->assertContains('The following commands are available:', $result);
$this->assertContains('To see the help of each command, enter:', $result);
$this->assertContains('bootstrap.php help', $result);
$this->assertStringContainsString('This is Yii version ', $result);
$this->assertStringContainsString('The following commands are available:', $result);
$this->assertStringContainsString('To see the help of each command, enter:', $result);
$this->assertStringContainsString('bootstrap.php help', $result);
}
public function testActionIndexWithHelpCommand()
{
$result = Console::stripAnsiFormat($this->runControllerAction('index', ['command' => 'help/index']));
$this->assertContains('Displays available commands or the detailed information', $result);
$this->assertContains('bootstrap.php help [command] [...options...]', $result);
$this->assertContains('--appconfig: string', $result);
$this->assertContains('- command: string', $result);
$this->assertContains('--color: boolean, 0 or 1', $result);
$this->assertContains('--help, -h: boolean, 0 or 1', $result);
$this->assertContains('--interactive: boolean, 0 or 1 (defaults to 1)', $result);
$this->assertStringContainsString('Displays available commands or the detailed information', $result);
$this->assertStringContainsString('bootstrap.php help [command] [...options...]', $result);
$this->assertStringContainsString('--appconfig: string', $result);
$this->assertStringContainsString('- command: string', $result);
$this->assertStringContainsString('--color: boolean, 0 or 1', $result);
$this->assertStringContainsString('--help, -h: boolean, 0 or 1', $result);
$this->assertStringContainsString('--interactive: boolean, 0 or 1 (defaults to 1)', $result);
}
public function testActionIndexWithServeCommand()
{
$result = Console::stripAnsiFormat($this->runControllerAction('index', ['command' => 'serve']));
$this->assertContains('Runs PHP built-in web server', $result);
$this->assertContains('bootstrap.php serve [address] [...options...]', $result);
$this->assertContains('- address: string (defaults to \'localhost\')', $result);
$this->assertContains('--appconfig: string', $result);
$this->assertContains('--color: boolean, 0 or 1', $result);
$this->assertContains('--docroot, -t: string (defaults to \'@app/web\')', $result);
$this->assertContains('--help, -h: boolean, 0 or 1', $result);
$this->assertContains('--interactive: boolean, 0 or 1 (defaults to 1)', $result);
$this->assertContains('--port, -p: int (defaults to 8080)', $result);
$this->assertContains('--router, -r: string', $result);
$this->assertStringContainsString('Runs PHP built-in web server', $result);
$this->assertStringContainsString('bootstrap.php serve [address] [...options...]', $result);
$this->assertStringContainsString('- address: string (defaults to \'localhost\')', $result);
$this->assertStringContainsString('--appconfig: string', $result);
$this->assertStringContainsString('--color: boolean, 0 or 1', $result);
$this->assertStringContainsString('--docroot, -t: string (defaults to \'@app/web\')', $result);
$this->assertStringContainsString('--help, -h: boolean, 0 or 1', $result);
$this->assertStringContainsString('--interactive: boolean, 0 or 1 (defaults to 1)', $result);
$this->assertStringContainsString('--port, -p: int (defaults to 8080)', $result);
$this->assertStringContainsString('--router, -r: string', $result);
}
public function testActionListContainsNoEmptyCommands()
@ -194,9 +194,9 @@ STRING
'controllerNamespace' => 'yiiunit\data\console\controllers',
]);
$result = Console::stripAnsiFormat($this->runControllerAction('list'));
$this->assertNotContains("fake-empty\n", $result);
$this->assertNotContains("fake-no-default\n", $result);
$this->assertContains("fake-no-default/index\n", $result);
$this->assertStringNotContainsString("fake-empty\n", $result);
$this->assertStringNotContainsString("fake-no-default\n", $result);
$this->assertStringContainsString("fake-no-default/index\n", $result);
}
public function testActionIndexContainsNoEmptyCommands()
@ -206,10 +206,10 @@ STRING
'controllerNamespace' => 'yiiunit\data\console\controllers',
]);
$result = Console::stripAnsiFormat($this->runControllerAction('index'));
$this->assertNotContains("- fake-empty", $result);
$this->assertContains("- fake-no-default", $result);
$this->assertContains(" fake-no-default/index", $result);
$this->assertNotContains(" fake-no-default/index (default)", $result);
$this->assertStringNotContainsString("- fake-empty", $result);
$this->assertStringContainsString("- fake-no-default", $result);
$this->assertStringContainsString(" fake-no-default/index", $result);
$this->assertStringNotContainsString(" fake-no-default/index (default)", $result);
}
}

View File

@ -26,7 +26,7 @@ class MigrateControllerTest extends TestCase
{
use MigrateControllerTestTrait;
public function setUp()
protected function setUp(): void
{
$this->migrateControllerClass = EchoMigrateController::className();
$this->migrationBaseClass = Migration::className();
@ -44,7 +44,7 @@ class MigrateControllerTest extends TestCase
parent::setUp();
}
public function tearDown()
protected function tearDown(): void
{
$this->tearDownMigrationPath();
parent::tearDown();
@ -419,8 +419,8 @@ class MigrateControllerTest extends TestCase
$result = $this->runMigrateControllerAction('up');
$this->assertSame(ExitCode::UNSPECIFIED_ERROR, $this->getExitCode());
$this->assertContains('The migration name', $result);
$this->assertContains('is too long. Its not possible to apply this migration.', $result);
$this->assertStringContainsString('The migration name', $result);
$this->assertStringContainsString('is too long. Its not possible to apply this migration.', $result);
}
public function testNamedMigrationWithCustomLimit()
@ -435,8 +435,8 @@ class MigrateControllerTest extends TestCase
$result = $this->runMigrateControllerAction('up');
$this->assertSame(ExitCode::OK, $this->getExitCode());
$this->assertContains('1 migration was applied.', $result);
$this->assertContains('Migrated up successfully.', $result);
$this->assertStringContainsString('1 migration was applied.', $result);
$this->assertStringContainsString('Migrated up successfully.', $result);
}
public function testCreateLongNamedMigration()
@ -478,11 +478,11 @@ class MigrateControllerTest extends TestCase
$this->assertSame(ExitCode::OK, $this->getExitCode());
// Drop worked
$this->assertContains('Table hall_of_fame dropped.', $result);
$this->assertContains('View view_hall_of_fame dropped.', $result);
$this->assertStringContainsString('Table hall_of_fame dropped.', $result);
$this->assertStringContainsString('View view_hall_of_fame dropped.', $result);
// Migration was restarted
$this->assertContains('No new migrations found. Your system is up-to-date.', $result);
$this->assertStringContainsString('No new migrations found. Your system is up-to-date.', $result);
}
public function refreshMigrationDataProvider()

View File

@ -228,7 +228,7 @@ CODE;
$this->assertSame(ExitCode::OK, $this->getExitCode());
$files = FileHelper::findFiles($this->migrationPath);
$this->assertCount(1, $files, 'Unable to create new migration!');
$this->assertContains($migrationName, basename($files[0]), 'Wrong migration name!');
$this->assertStringContainsString($migrationName, basename($files[0]), 'Wrong migration name!');
}
public function testUp()
@ -294,7 +294,7 @@ CODE;
public function testHistory()
{
$output = $this->runMigrateControllerAction('history');
$this->assertContains('No migration', $output);
$this->assertStringContainsString('No migration', $output);
$this->createMigration('test_history1');
$this->createMigration('test_history2');
@ -303,8 +303,8 @@ CODE;
$output = $this->runMigrateControllerAction('history');
$this->assertSame(ExitCode::OK, $this->getExitCode());
$this->assertContains('_test_history1', $output);
$this->assertContains('_test_history2', $output);
$this->assertStringContainsString('_test_history1', $output);
$this->assertStringContainsString('_test_history2', $output);
}
/**
@ -316,7 +316,7 @@ CODE;
$output = $this->runMigrateControllerAction('new');
$this->assertSame(ExitCode::OK, $this->getExitCode());
$this->assertContains('_test_new1', $output);
$this->assertStringContainsString('_test_new1', $output);
$this->runMigrateControllerAction('up');
$this->assertSame(ExitCode::OK, $this->getExitCode());
@ -393,8 +393,8 @@ CODE;
$this->assertSame(ExitCode::OK, $this->getExitCode());
$files = FileHelper::findFiles($this->migrationPath);
$fileContent = file_get_contents($files[0]);
$this->assertContains("namespace {$this->migrationNamespace};", $fileContent);
$this->assertRegExp('/class M[0-9]{12}' . ucfirst($migrationName) . '/s', $fileContent);
$this->assertStringContainsString("namespace {$this->migrationNamespace};", $fileContent);
$this->assertMatchesRegularExpression('/class M[0-9]{12}' . ucfirst($migrationName) . '/s', $fileContent);
unlink($files[0]);
// namespace specify :
@ -406,7 +406,7 @@ CODE;
$this->assertSame(ExitCode::OK, $this->getExitCode());
$files = FileHelper::findFiles($this->migrationPath);
$fileContent = file_get_contents($files[0]);
$this->assertContains("namespace {$this->migrationNamespace};", $fileContent);
$this->assertStringContainsString("namespace {$this->migrationNamespace};", $fileContent);
unlink($files[0]);
// no namespace:
@ -478,7 +478,7 @@ CODE;
];
$output = $this->runMigrateControllerAction('history', [], $controllerConfig);
$this->assertContains('No migration', $output);
$this->assertStringContainsString('No migration', $output);
$this->createNamespaceMigration('history1');
$this->createNamespaceMigration('history2');
@ -487,8 +487,8 @@ CODE;
$output = $this->runMigrateControllerAction('history', [], $controllerConfig);
$this->assertSame(ExitCode::OK, $this->getExitCode());
$this->assertRegExp('/' . preg_quote($this->migrationNamespace) . '.*History1/s', $output);
$this->assertRegExp('/' . preg_quote($this->migrationNamespace) . '.*History2/s', $output);
$this->assertMatchesRegularExpression('/' . preg_quote($this->migrationNamespace) . '.*History1/s', $output);
$this->assertMatchesRegularExpression('/' . preg_quote($this->migrationNamespace) . '.*History2/s', $output);
}
/**

View File

@ -18,14 +18,14 @@ class PHPMessageControllerTest extends BaseMessageControllerTest
{
protected $messagePath;
public function setUp()
protected function setUp(): void
{
parent::setUp();
$this->messagePath = Yii::getAlias('@yiiunit/runtime/test_messages');
FileHelper::createDirectory($this->messagePath, 0777);
}
public function tearDown()
protected function tearDown(): void
{
parent::tearDown();
FileHelper::removeDirectory($this->messagePath);
@ -165,7 +165,7 @@ class PHPMessageControllerTest extends BaseMessageControllerTest
if ($isExpectedToExist) {
$this->assertFileExists($filePath);
} else {
$this->assertFileNotExists($filePath);
$this->assertFileDoesNotExist($filePath);
}
}
}

View File

@ -19,7 +19,7 @@ class POMessageControllerTest extends BaseMessageControllerTest
protected $messagePath;
protected $catalog = 'messages';
public function setUp()
protected function setUp(): void
{
parent::setUp();
@ -27,7 +27,7 @@ class POMessageControllerTest extends BaseMessageControllerTest
FileHelper::createDirectory($this->messagePath, 0777);
}
public function tearDown()
protected function tearDown(): void
{
parent::tearDown();
FileHelper::removeDirectory($this->messagePath);

View File

@ -19,7 +19,7 @@ use yiiunit\TestCase;
*/
class ServeControllerTest extends TestCase
{
public function setUp()
protected function setUp(): void
{
$this->mockApplication();
}
@ -46,7 +46,7 @@ class ServeControllerTest extends TestCase
$result = $serveController->flushStdOutBuffer();
$this->assertContains('http://localhost:8080 is taken by another process.', $result);
$this->assertStringContainsString('http://localhost:8080 is taken by another process.', $result);
}
public function testDefaultValues()
@ -70,9 +70,9 @@ class ServeControllerTest extends TestCase
$result = $serveController->flushStdOutBuffer();
$this->assertContains('Server started on http://localhost:8080', $result);
$this->assertContains("Document root is \"{$docroot}\"", $result);
$this->assertContains('Quit the server with CTRL-C or COMMAND-C.', $result);
$this->assertStringContainsString('Server started on http://localhost:8080', $result);
$this->assertStringContainsString("Document root is \"{$docroot}\"", $result);
$this->assertStringContainsString('Quit the server with CTRL-C or COMMAND-C.', $result);
}
public function testDoocRootWithNoExistValue()
@ -95,7 +95,7 @@ class ServeControllerTest extends TestCase
$result = $serveController->flushStdOutBuffer();
$this->assertContains("Document root \"{$docroot}\" does not exist.", $result);
$this->assertStringContainsString("Document root \"{$docroot}\" does not exist.", $result);
}
public function testWithRouterNoExistValue()
@ -121,7 +121,7 @@ class ServeControllerTest extends TestCase
$result = $serveController->flushStdOutBuffer();
$this->assertContains("Routing file \"$router\" does not exist.", $result);
$this->assertStringContainsString("Routing file \"$router\" does not exist.", $result);
}
public function testWithRouterValue()
@ -147,10 +147,10 @@ class ServeControllerTest extends TestCase
$result = $serveController->flushStdOutBuffer();
$this->assertContains('Server started on http://localhost:8081', $result);
$this->assertContains("Document root is \"{$docroot}\"", $result);
$this->assertContains("Routing file is \"{$router}\"", $result);
$this->assertContains('Quit the server with CTRL-C or COMMAND-C.', $result);
$this->assertStringContainsString('Server started on http://localhost:8081', $result);
$this->assertStringContainsString("Document root is \"{$docroot}\"", $result);
$this->assertStringContainsString("Routing file is \"{$router}\"", $result);
$this->assertStringContainsString('Quit the server with CTRL-C or COMMAND-C.', $result);
}
}