Merge pull request #448 from 2618094/php8-upgrade

Php8 upgrade
This commit is contained in:
Andrés Montañez 2021-02-18 21:28:58 -03:00 committed by GitHub
commit 7363a84853
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 104 additions and 98 deletions

2
.gitignore vendored Normal file → Executable file
View file

@ -2,3 +2,5 @@
/build /build
composer.lock composer.lock
.mage.yml .mage.yml
.idea
.phpunit.result.cache

3
.travis.yml Normal file → Executable file
View file

@ -1,7 +1,8 @@
language: php language: php
php: php:
- '7.1'
- '7.2' - '7.2'
- '7.4'
- '8.0'
install: install:
- composer install - composer install

23
composer.json Normal file → Executable file
View file

@ -12,18 +12,21 @@
} }
], ],
"require": { "require": {
"php": "^7.1.3", "php": "^7.2 | ^8.0",
"monolog/monolog": "~1.11", "monolog/monolog": "~1.11 | ^2.0",
"symfony/console": "^4.0", "symfony/console": "^4.0 | ^5.0",
"symfony/filesystem": "^4.0", "symfony/filesystem": "^4.0 | ^5.0",
"symfony/event-dispatcher": "^4.0", "symfony/event-dispatcher": "^4.0 | ^5.0",
"symfony/finder": "^4.0", "symfony/finder": "^4.0 | ^5.0",
"symfony/yaml": "^4.0", "symfony/yaml": "^4.0 | ^5.0",
"symfony/process": "^4.0" "symfony/process": "^4.0 | ^5.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^7.0", "phpunit/phpunit": "^8.0",
"satooshi/php-coveralls": "~1.0" "php-coveralls/php-coveralls": "~2.0"
},
"suggest": {
"ext-posix": "*"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

4
src/Deploy/Strategy/ReleasesStrategy.php Normal file → Executable file
View file

@ -110,13 +110,13 @@ class ReleasesStrategy implements StrategyInterface
/** /**
* Check the runtime stage is correct * Check the runtime stage is correct
* *
* @param $stage * @param string $stage
* @throws RuntimeException * @throws RuntimeException
*/ */
private function checkStage($stage) private function checkStage($stage)
{ {
if ($this->runtime->getStage() !== $stage) { if ($this->runtime->getStage() !== $stage) {
throw new RuntimeException(sprintf('Invalid stage, got "%s" but expected "%"', $this->runtime->getStage(), $stage)); throw new RuntimeException(sprintf('Invalid stage, got "%s" but expected "%s"', $this->runtime->getStage(), $stage));
} }
} }
} }

2
src/Deploy/Strategy/RsyncStrategy.php Normal file → Executable file
View file

@ -90,7 +90,7 @@ class RsyncStrategy implements StrategyInterface
private function checkStage($stage) private function checkStage($stage)
{ {
if ($this->runtime->getStage() !== $stage) { if ($this->runtime->getStage() !== $stage) {
throw new RuntimeException(sprintf('Invalid stage, got "%s" but expected "%"', $this->runtime->getStage(), $stage)); throw new RuntimeException(sprintf('Invalid stage, got "%s" but expected "%s"', $this->runtime->getStage(), $stage));
} }
} }
} }

2
src/Runtime/Runtime.php Normal file → Executable file
View file

@ -405,7 +405,7 @@ class Runtime
{ {
$this->log($cmd, LogLevel::INFO); $this->log($cmd, LogLevel::INFO);
$process = new Process($cmd); $process = Process::fromShellCommandline($cmd);
$process->setTimeout($timeout); $process->setTimeout($timeout);
$process->run(); $process->run();

8
tests/Command/BuiltIn/DeployCommandMiscTasksTest.php Normal file → Executable file
View file

@ -154,7 +154,7 @@ class DeployCommandMiscTasksTest extends TestCase
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertEquals(7, $tester->getStatusCode()); $this->assertEquals(7, $tester->getStatusCode());
$this->assertContains('Invalid task name "invalid/task"', $tester->getDisplay()); $this->assertStringContainsString('Invalid task name "invalid/task"', $tester->getDisplay());
} }
public function testBrokenGitBranch() public function testBrokenGitBranch()
@ -171,7 +171,7 @@ class DeployCommandMiscTasksTest extends TestCase
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertContains('Running [Git] Change Branch (broken-test) ... FAIL', $tester->getDisplay()); $this->assertStringContainsString('Running [Git] Change Branch (broken-test) ... FAIL', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
@ -189,7 +189,7 @@ class DeployCommandMiscTasksTest extends TestCase
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertContains('Running [Git] Change Branch (broken-test) ... FAIL', $tester->getDisplay()); $this->assertStringContainsString('Running [Git] Change Branch (broken-test) ... FAIL', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
@ -207,7 +207,7 @@ class DeployCommandMiscTasksTest extends TestCase
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertContains('Running [Git] Update ... FAIL', $tester->getDisplay()); $this->assertStringContainsString('Running [Git] Update ... FAIL', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
} }

6
tests/Command/BuiltIn/DeployCommandMiscTest.php Normal file → Executable file
View file

@ -30,9 +30,9 @@ class DeployCommandMiscTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertContains('No hosts defined, skipping On Deploy tasks', $tester->getDisplay()); $this->assertStringContainsString('No hosts defined, skipping On Deploy tasks', $tester->getDisplay());
$this->assertContains('No hosts defined, skipping On Release tasks', $tester->getDisplay()); $this->assertStringContainsString('No hosts defined, skipping On Release tasks', $tester->getDisplay());
$this->assertContains('No hosts defined, skipping Post Release tasks', $tester->getDisplay()); $this->assertStringContainsString('No hosts defined, skipping Post Release tasks', $tester->getDisplay());
$this->assertEquals(0, $tester->getStatusCode()); $this->assertEquals(0, $tester->getStatusCode());
} }

26
tests/Command/BuiltIn/DeployCommandWithReleasesTest.php Normal file → Executable file
View file

@ -179,7 +179,7 @@ class DeployCommandWithReleasesTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertContains('This task is only available with releases enabled', $tester->getDisplay()); $this->assertStringContainsString('This task is only available with releases enabled', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
@ -194,7 +194,7 @@ class DeployCommandWithReleasesTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertContains('This task is only available with releases enabled', $tester->getDisplay()); $this->assertStringContainsString('This task is only available with releases enabled', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
@ -209,7 +209,7 @@ class DeployCommandWithReleasesTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertContains('This task is only available with releases enabled', $tester->getDisplay()); $this->assertStringContainsString('This task is only available with releases enabled', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
@ -224,7 +224,7 @@ class DeployCommandWithReleasesTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertContains('Copying files with Tar ... FAIL', $tester->getDisplay()); $this->assertStringContainsString('Copying files with Tar ... FAIL', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
@ -239,7 +239,7 @@ class DeployCommandWithReleasesTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertContains('This task is only available with releases enabled', $tester->getDisplay()); $this->assertStringContainsString('This task is only available with releases enabled', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
@ -280,8 +280,8 @@ class DeployCommandWithReleasesTest extends TestCase
$this->assertEquals($command, $ranCommands[$index]); $this->assertEquals($command, $ranCommands[$index]);
} }
$this->assertContains('Running [Deploy] Copying files with Tar ... FAIL', $tester->getDisplay()); $this->assertStringContainsString('Running [Deploy] Copying files with Tar ... FAIL', $tester->getDisplay());
$this->assertContains('Stage "On Deploy" did not finished successfully, halting command.', $tester->getDisplay()); $this->assertStringContainsString('Stage "On Deploy" did not finished successfully, halting command.', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
@ -321,8 +321,8 @@ class DeployCommandWithReleasesTest extends TestCase
$this->assertEquals($command, $ranCommands[$index]); $this->assertEquals($command, $ranCommands[$index]);
} }
$this->assertContains('Running [Deploy] Copying files with Tar ... FAIL', $tester->getDisplay()); $this->assertStringContainsString('Running [Deploy] Copying files with Tar ... FAIL', $tester->getDisplay());
$this->assertContains('Stage "On Deploy" did not finished successfully, halting command.', $tester->getDisplay()); $this->assertStringContainsString('Stage "On Deploy" did not finished successfully, halting command.', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
@ -374,8 +374,8 @@ class DeployCommandWithReleasesTest extends TestCase
$this->assertEquals($command, $ranCommands[$index]); $this->assertEquals($command, $ranCommands[$index]);
} }
$this->assertContains('Running [Deploy] Cleanup Tar file ... FAIL', $tester->getDisplay()); $this->assertStringContainsString('Running [Deploy] Cleanup Tar file ... FAIL', $tester->getDisplay());
$this->assertContains('Stage "Post Deploy" did not finished successfully, halting command.', $tester->getDisplay()); $this->assertStringContainsString('Stage "Post Deploy" did not finished successfully, halting command.', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
@ -422,8 +422,8 @@ class DeployCommandWithReleasesTest extends TestCase
$this->assertEquals($command, $ranCommands[$index]); $this->assertEquals($command, $ranCommands[$index]);
} }
$this->assertContains('Running [Release] Cleaning up old Releases ... FAIL', $tester->getDisplay()); $this->assertStringContainsString('Running [Release] Cleaning up old Releases ... FAIL', $tester->getDisplay());
$this->assertContains('Stage "Post Release" did not finished successfully, halting command.', $tester->getDisplay()); $this->assertStringContainsString('Stage "Post Release" did not finished successfully, halting command.', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
} }

View file

@ -161,7 +161,7 @@ class DeployCommandWithoutReleasesTest extends TestCase
$this->assertEquals($command, $ranCommands[$index]); $this->assertEquals($command, $ranCommands[$index]);
} }
$this->assertContains('Stage "On Deploy" did not finished successfully, halting command.', $tester->getDisplay()); $this->assertStringContainsString('Stage "On Deploy" did not finished successfully, halting command.', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
} }

12
tests/Command/BuiltIn/Releases/ListCommandTest.php Normal file → Executable file
View file

@ -57,7 +57,7 @@ class ListCommandTest extends TestCase
$tester->execute(['command' => $command->getName(), 'environment' => 'developers']); $tester->execute(['command' => $command->getName(), 'environment' => 'developers']);
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
$this->assertContains('The environment "developers" does not exists.', $tester->getDisplay()); $this->assertStringContainsString('The environment "developers" does not exists.', $tester->getDisplay());
} }
public function testListReleasesWithoutReleases() public function testListReleasesWithoutReleases()
@ -72,7 +72,7 @@ class ListCommandTest extends TestCase
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
$this->assertContains('Releases are not enabled', $tester->getDisplay()); $this->assertStringContainsString('Releases are not enabled', $tester->getDisplay());
} }
public function testFailToGetCurrentRelease() public function testFailToGetCurrentRelease()
@ -87,7 +87,7 @@ class ListCommandTest extends TestCase
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
$this->assertContains('Unable to retrieve current release from host "host1"', $tester->getDisplay()); $this->assertStringContainsString('Unable to retrieve current release from host "host1"', $tester->getDisplay());
} }
public function testNoReleasesAvailable() public function testNoReleasesAvailable()
@ -101,7 +101,7 @@ class ListCommandTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertContains('No releases available on host host2', $tester->getDisplay()); $this->assertStringContainsString('No releases available on host host2', $tester->getDisplay());
} }
public function testFailGetReleases() public function testFailGetReleases()
@ -116,7 +116,7 @@ class ListCommandTest extends TestCase
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
$this->assertContains('Unable to retrieve releases from host "host3"', $tester->getDisplay()); $this->assertStringContainsString('Unable to retrieve releases from host "host3"', $tester->getDisplay());
} }
public function testNoHosts() public function testNoHosts()
@ -130,6 +130,6 @@ class ListCommandTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'test']); $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertContains('No hosts defined', $tester->getDisplay()); $this->assertStringContainsString('No hosts defined', $tester->getDisplay());
} }
} }

6
tests/Command/BuiltIn/Releases/RollbackCommandTest.php Normal file → Executable file
View file

@ -57,7 +57,7 @@ class RollbackCommandTest extends TestCase
$tester->execute(['command' => $command->getName(), 'environment' => 'developers', 'release' => '20170101015115']); $tester->execute(['command' => $command->getName(), 'environment' => 'developers', 'release' => '20170101015115']);
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
$this->assertContains('The environment "developers" does not exists.', $tester->getDisplay()); $this->assertStringContainsString('The environment "developers" does not exists.', $tester->getDisplay());
} }
public function testRollbackReleaseWithoutReleases() public function testRollbackReleaseWithoutReleases()
@ -72,7 +72,7 @@ class RollbackCommandTest extends TestCase
$tester->execute(['command' => $command->getName(), 'environment' => 'test', 'release' => '20170101015115']); $tester->execute(['command' => $command->getName(), 'environment' => 'test', 'release' => '20170101015115']);
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
$this->assertContains('Releases are not enabled', $tester->getDisplay()); $this->assertStringContainsString('Releases are not enabled', $tester->getDisplay());
} }
public function testRollbackReleaseNotAvailable() public function testRollbackReleaseNotAvailable()
@ -87,6 +87,6 @@ class RollbackCommandTest extends TestCase
$tester->execute(['command' => $command->getName(), 'environment' => 'test', 'release' => '20170101015115']); $tester->execute(['command' => $command->getName(), 'environment' => 'test', 'release' => '20170101015115']);
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
$this->assertContains('Release "20170101015115" is not available on all hosts', $tester->getDisplay()); $this->assertStringContainsString('Release "20170101015115" is not available on all hosts', $tester->getDisplay());
} }
} }

20
tests/Deploy/StrategyTest.php Normal file → Executable file
View file

@ -31,7 +31,7 @@ class StrategyTest extends TestCase
$rsync->getPreDeployTasks(); $rsync->getPreDeployTasks();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%"', Runtime::ON_DEPLOY, Runtime::PRE_DEPLOY), $exception->getMessage()); $this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%s"', Runtime::ON_DEPLOY, Runtime::PRE_DEPLOY), $exception->getMessage());
} }
try { try {
@ -39,7 +39,7 @@ class StrategyTest extends TestCase
$rsync->getOnDeployTasks(); $rsync->getOnDeployTasks();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%"', Runtime::PRE_DEPLOY, Runtime::ON_DEPLOY), $exception->getMessage()); $this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%s"', Runtime::PRE_DEPLOY, Runtime::ON_DEPLOY), $exception->getMessage());
} }
try { try {
@ -47,7 +47,7 @@ class StrategyTest extends TestCase
$rsync->getOnReleaseTasks(); $rsync->getOnReleaseTasks();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%"', Runtime::PRE_DEPLOY, Runtime::ON_RELEASE), $exception->getMessage()); $this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%s"', Runtime::PRE_DEPLOY, Runtime::ON_RELEASE), $exception->getMessage());
} }
try { try {
@ -55,7 +55,7 @@ class StrategyTest extends TestCase
$rsync->getPostReleaseTasks(); $rsync->getPostReleaseTasks();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%"', Runtime::PRE_DEPLOY, Runtime::POST_RELEASE), $exception->getMessage()); $this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%s"', Runtime::PRE_DEPLOY, Runtime::POST_RELEASE), $exception->getMessage());
} }
try { try {
@ -63,7 +63,7 @@ class StrategyTest extends TestCase
$rsync->getPostDeployTasks(); $rsync->getPostDeployTasks();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%"', Runtime::PRE_DEPLOY, Runtime::POST_DEPLOY), $exception->getMessage()); $this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%s"', Runtime::PRE_DEPLOY, Runtime::POST_DEPLOY), $exception->getMessage());
} }
} }
@ -79,7 +79,7 @@ class StrategyTest extends TestCase
$releases->getPreDeployTasks(); $releases->getPreDeployTasks();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%"', Runtime::ON_DEPLOY, Runtime::PRE_DEPLOY), $exception->getMessage()); $this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%s"', Runtime::ON_DEPLOY, Runtime::PRE_DEPLOY), $exception->getMessage());
} }
try { try {
@ -87,7 +87,7 @@ class StrategyTest extends TestCase
$releases->getOnDeployTasks(); $releases->getOnDeployTasks();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%"', Runtime::PRE_DEPLOY, Runtime::ON_DEPLOY), $exception->getMessage()); $this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%s"', Runtime::PRE_DEPLOY, Runtime::ON_DEPLOY), $exception->getMessage());
} }
try { try {
@ -95,7 +95,7 @@ class StrategyTest extends TestCase
$releases->getOnReleaseTasks(); $releases->getOnReleaseTasks();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%"', Runtime::PRE_DEPLOY, Runtime::ON_RELEASE), $exception->getMessage()); $this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%s"', Runtime::PRE_DEPLOY, Runtime::ON_RELEASE), $exception->getMessage());
} }
try { try {
@ -103,7 +103,7 @@ class StrategyTest extends TestCase
$releases->getPostReleaseTasks(); $releases->getPostReleaseTasks();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%"', Runtime::PRE_DEPLOY, Runtime::POST_RELEASE), $exception->getMessage()); $this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%s"', Runtime::PRE_DEPLOY, Runtime::POST_RELEASE), $exception->getMessage());
} }
try { try {
@ -111,7 +111,7 @@ class StrategyTest extends TestCase
$releases->getPostDeployTasks(); $releases->getPostDeployTasks();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%"', Runtime::PRE_DEPLOY, Runtime::POST_DEPLOY), $exception->getMessage()); $this->assertEquals(sprintf('Invalid stage, got "%s" but expected "%s"', Runtime::PRE_DEPLOY, Runtime::POST_DEPLOY), $exception->getMessage());
} }
} }

2
tests/MageApplicationTest.php Normal file → Executable file
View file

@ -73,6 +73,6 @@ class MageApplicationTest extends TestCase
$tester = new ApplicationTester($application); $tester = new ApplicationTester($application);
$tester->run(['command' => 'foo']); $tester->run(['command' => 'foo']);
$this->assertContains('Oops, exception thrown while running command foo', $tester->getDisplay()); $this->assertStringContainsString('Oops, exception thrown while running command foo', $tester->getDisplay());
} }
} }

0
tests/Runtime/RuntimeTest.php Normal file → Executable file
View file

0
tests/Task/BuiltIn/Composer/BasicComposerTaskTest.php Normal file → Executable file
View file

6
tests/Task/BuiltIn/ExecTaskTest.php Normal file → Executable file
View file

@ -28,7 +28,7 @@ class ExecTest extends TestCase
$task->setOptions(['cmd' => 'ls -l', 'desc' => 'Loading docker']); $task->setOptions(['cmd' => 'ls -l', 'desc' => 'Loading docker']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('[Exec] Loading docker', $task->getDescription()); $this->assertStringContainsString('[Exec] Loading docker', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -56,7 +56,7 @@ class ExecTest extends TestCase
$task->setOptions(['cmd' => 'ls -la']); $task->setOptions(['cmd' => 'ls -la']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('[Exec] Custom command', $task->getDescription()); $this->assertStringContainsString('[Exec] Custom command', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -84,7 +84,7 @@ class ExecTest extends TestCase
$task->setOptions(['desc' => 'Loading docker']); $task->setOptions(['desc' => 'Loading docker']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('[Exec] Loading docker', $task->getDescription()); $this->assertStringContainsString('[Exec] Loading docker', $task->getDescription());
try { try {
$task->execute(); $task->execute();

14
tests/Task/BuiltIn/FileSystem/ChangeModeTaskTest.php Normal file → Executable file
View file

@ -28,8 +28,8 @@ class ChangeModeTest extends TestCase
$task->setOptions(['file' => 'a.txt', 'flags' => '-R', 'mode' => 'o+w']); $task->setOptions(['file' => 'a.txt', 'flags' => '-R', 'mode' => 'o+w']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription()); $this->assertStringContainsString('a.txt', $task->getDescription());
$this->assertContains('o+w', $task->getDescription()); $this->assertStringContainsString('o+w', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -57,8 +57,8 @@ class ChangeModeTest extends TestCase
$task->setOptions(['file' => 'a.txt', 'mode' => 'o+w']); $task->setOptions(['file' => 'a.txt', 'mode' => 'o+w']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription()); $this->assertStringContainsString('a.txt', $task->getDescription());
$this->assertContains('o+w', $task->getDescription()); $this->assertStringContainsString('o+w', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -86,8 +86,8 @@ class ChangeModeTest extends TestCase
$task->setOptions(['file' => '%environment%.txt', 'flags' => '-R', 'mode' => 'o+w']); $task->setOptions(['file' => '%environment%.txt', 'flags' => '-R', 'mode' => 'o+w']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('test.txt', $task->getDescription()); $this->assertStringContainsString('test.txt', $task->getDescription());
$this->assertContains('o+w', $task->getDescription()); $this->assertStringContainsString('o+w', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -116,7 +116,7 @@ class ChangeModeTest extends TestCase
$task->setRuntime($runtime); $task->setRuntime($runtime);
try { try {
$this->assertContains('[missing parameters]', $task->getDescription()); $this->assertStringContainsString('[missing parameters]', $task->getDescription());
$task->execute(); $task->execute();
$this->assertTrue(false, 'Task should have raised an exception'); $this->assertTrue(false, 'Task should have raised an exception');
} catch (Exception $exception) { } catch (Exception $exception) {

18
tests/Task/BuiltIn/FileSystem/CopyTaskTest.php Normal file → Executable file
View file

@ -28,8 +28,8 @@ class CopyTaskTest extends TestCase
$task->setOptions(['from' => 'a.txt', 'to' => 'b.txt']); $task->setOptions(['from' => 'a.txt', 'to' => 'b.txt']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription()); $this->assertStringContainsString('a.txt', $task->getDescription());
$this->assertContains('b.txt', $task->getDescription()); $this->assertStringContainsString('b.txt', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -57,8 +57,8 @@ class CopyTaskTest extends TestCase
$task->setOptions(['from' => 'a.txt', 'to' => 'b.txt', 'flags' => '-rp']); $task->setOptions(['from' => 'a.txt', 'to' => 'b.txt', 'flags' => '-rp']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription()); $this->assertStringContainsString('a.txt', $task->getDescription());
$this->assertContains('b.txt', $task->getDescription()); $this->assertStringContainsString('b.txt', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -86,8 +86,8 @@ class CopyTaskTest extends TestCase
$task->setOptions(['from' => '%environment%.txt', 'to' => 'b.txt']); $task->setOptions(['from' => '%environment%.txt', 'to' => 'b.txt']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('test.txt', $task->getDescription()); $this->assertStringContainsString('test.txt', $task->getDescription());
$this->assertContains('b.txt', $task->getDescription()); $this->assertStringContainsString('b.txt', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -117,8 +117,8 @@ class CopyTaskTest extends TestCase
$task->setOptions(['from' => '%host%.txt', 'to' => '%release%.yml']); $task->setOptions(['from' => '%host%.txt', 'to' => '%release%.yml']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('localhost.txt', $task->getDescription()); $this->assertStringContainsString('localhost.txt', $task->getDescription());
$this->assertContains('1234.yml', $task->getDescription()); $this->assertStringContainsString('1234.yml', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -147,7 +147,7 @@ class CopyTaskTest extends TestCase
$task->setRuntime($runtime); $task->setRuntime($runtime);
try { try {
$this->assertContains('[missing parameters]', $task->getDescription()); $this->assertStringContainsString('[missing parameters]', $task->getDescription());
$task->execute(); $task->execute();
$this->assertTrue(false, 'Task did not failed'); $this->assertTrue(false, 'Task did not failed');
} catch (Exception $exception) { } catch (Exception $exception) {

14
tests/Task/BuiltIn/FileSystem/LinkTaskTest.php Normal file → Executable file
View file

@ -28,8 +28,8 @@ class LinkTaskTest extends TestCase
$task->setOptions(['from' => 'a.txt', 'to' => 'b.txt']); $task->setOptions(['from' => 'a.txt', 'to' => 'b.txt']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription()); $this->assertStringContainsString('a.txt', $task->getDescription());
$this->assertContains('b.txt', $task->getDescription()); $this->assertStringContainsString('b.txt', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -57,8 +57,8 @@ class LinkTaskTest extends TestCase
$task->setOptions(['from' => 'a.txt', 'to' => 'b.txt', 'flags' => '-P']); $task->setOptions(['from' => 'a.txt', 'to' => 'b.txt', 'flags' => '-P']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription()); $this->assertStringContainsString('a.txt', $task->getDescription());
$this->assertContains('b.txt', $task->getDescription()); $this->assertStringContainsString('b.txt', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -86,8 +86,8 @@ class LinkTaskTest extends TestCase
$task->setOptions(['from' => '%environment%.txt', 'to' => 'b.txt']); $task->setOptions(['from' => '%environment%.txt', 'to' => 'b.txt']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('test.txt', $task->getDescription()); $this->assertStringContainsString('test.txt', $task->getDescription());
$this->assertContains('b.txt', $task->getDescription()); $this->assertStringContainsString('b.txt', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -116,7 +116,7 @@ class LinkTaskTest extends TestCase
$task->setRuntime($runtime); $task->setRuntime($runtime);
try { try {
$this->assertContains('[missing parameters]', $task->getDescription()); $this->assertStringContainsString('[missing parameters]', $task->getDescription());
$task->execute(); $task->execute();
$this->assertTrue(false, 'Task did not failed'); $this->assertTrue(false, 'Task did not failed');
} catch (Exception $exception) { } catch (Exception $exception) {

14
tests/Task/BuiltIn/FileSystem/MoveTaskTest.php Normal file → Executable file
View file

@ -28,8 +28,8 @@ class MoveTaskTest extends TestCase
$task->setOptions(['from' => 'a.txt', 'to' => 'b.txt']); $task->setOptions(['from' => 'a.txt', 'to' => 'b.txt']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription()); $this->assertStringContainsString('a.txt', $task->getDescription());
$this->assertContains('b.txt', $task->getDescription()); $this->assertStringContainsString('b.txt', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -57,8 +57,8 @@ class MoveTaskTest extends TestCase
$task->setOptions(['from' => 'a.txt', 'to' => 'b.txt', 'flags' => '-n']); $task->setOptions(['from' => 'a.txt', 'to' => 'b.txt', 'flags' => '-n']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription()); $this->assertStringContainsString('a.txt', $task->getDescription());
$this->assertContains('b.txt', $task->getDescription()); $this->assertStringContainsString('b.txt', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -86,8 +86,8 @@ class MoveTaskTest extends TestCase
$task->setOptions(['from' => '%environment%.txt', 'to' => 'b.txt']); $task->setOptions(['from' => '%environment%.txt', 'to' => 'b.txt']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('test.txt', $task->getDescription()); $this->assertStringContainsString('test.txt', $task->getDescription());
$this->assertContains('b.txt', $task->getDescription()); $this->assertStringContainsString('b.txt', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -116,7 +116,7 @@ class MoveTaskTest extends TestCase
$task->setRuntime($runtime); $task->setRuntime($runtime);
try { try {
$this->assertContains('[missing parameters]', $task->getDescription()); $this->assertStringContainsString('[missing parameters]', $task->getDescription());
$task->execute(); $task->execute();
$this->assertTrue(false, 'Task did not failed'); $this->assertTrue(false, 'Task did not failed');
} catch (Exception $exception) { } catch (Exception $exception) {

8
tests/Task/BuiltIn/FileSystem/RemoveTaskTest.php Normal file → Executable file
View file

@ -28,7 +28,7 @@ class RemoveTaskTest extends TestCase
$task->setOptions(['file' => 'a.txt']); $task->setOptions(['file' => 'a.txt']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription()); $this->assertStringContainsString('a.txt', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -56,7 +56,7 @@ class RemoveTaskTest extends TestCase
$task->setOptions(['file' => 'a.txt', 'flags' => '-fr']); $task->setOptions(['file' => 'a.txt', 'flags' => '-fr']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription()); $this->assertStringContainsString('a.txt', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -84,7 +84,7 @@ class RemoveTaskTest extends TestCase
$task->setOptions(['file' => '%environment%.txt']); $task->setOptions(['file' => '%environment%.txt']);
$task->setRuntime($runtime); $task->setRuntime($runtime);
$this->assertContains('test.txt', $task->getDescription()); $this->assertStringContainsString('test.txt', $task->getDescription());
$task->execute(); $task->execute();
$ranCommands = $runtime->getRanCommands(); $ranCommands = $runtime->getRanCommands();
@ -113,7 +113,7 @@ class RemoveTaskTest extends TestCase
$task->setRuntime($runtime); $task->setRuntime($runtime);
try { try {
$this->assertContains('[missing parameters]', $task->getDescription()); $this->assertStringContainsString('[missing parameters]', $task->getDescription());
$task->execute(); $task->execute();
$this->assertTrue(false, 'Task did not failed'); $this->assertTrue(false, 'Task did not failed');
} catch (Exception $exception) { } catch (Exception $exception) {

2
tests/Task/BuiltIn/Symfony/CachePoolClearTaskTest.php Normal file → Executable file
View file

@ -15,7 +15,7 @@ class CachePoolClearTaskTest extends TestCase
*/ */
private $runtime; private $runtime;
public function setUp() public function setUp(): void
{ {
$this->runtime = new RuntimeMockup(); $this->runtime = new RuntimeMockup();
$this->runtime->setConfiguration(['environments' => ['test' => []]]); $this->runtime->setConfiguration(['environments' => ['test' => []]]);

8
tests/Task/TaskFactoryTest.php Normal file → Executable file
View file

@ -59,7 +59,7 @@ class TaskFactoryTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'production']); $tester->execute(['command' => $command->getName(), 'environment' => 'production']);
$this->assertContains('[Custom] Valid*', $tester->getDisplay()); $this->assertStringContainsString('[Custom] Valid*', $tester->getDisplay());
$ranCommands = $application->getRuntime()->getRanCommands(); $ranCommands = $application->getRuntime()->getRanCommands();
@ -90,7 +90,7 @@ class TaskFactoryTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'production']); $tester->execute(['command' => $command->getName(), 'environment' => 'production']);
$this->assertContains('Custom Task "Mage\Tests\Task\Custom\InvalidClass" does not exists.', $tester->getDisplay()); $this->assertStringContainsString('Custom Task "Mage\Tests\Task\Custom\InvalidClass" does not exists.', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
@ -106,7 +106,7 @@ class TaskFactoryTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'production']); $tester->execute(['command' => $command->getName(), 'environment' => 'production']);
$this->assertContains('Custom Task "Mage\Tests\Task\Custom\NotInstantiableTask" can not be instantiated.', $tester->getDisplay()); $this->assertStringContainsString('Custom Task "Mage\Tests\Task\Custom\NotInstantiableTask" can not be instantiated.', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }
@ -122,7 +122,7 @@ class TaskFactoryTest extends TestCase
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'production']); $tester->execute(['command' => $command->getName(), 'environment' => 'production']);
$this->assertContains('Custom Task "Mage\Tests\Task\Custom\InvalidInheritanceTask" must inherit "Mage\Task\AbstractTask".', $tester->getDisplay()); $this->assertStringContainsString('Custom Task "Mage\Tests\Task\Custom\InvalidInheritanceTask" must inherit "Mage\Task\AbstractTask".', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode()); $this->assertNotEquals(0, $tester->getStatusCode());
} }