From 05d9cf0b806945abf4ab474bc748055ac739e436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Thu, 29 Mar 2018 20:19:35 -0300 Subject: [PATCH] [Discovery One] Upgrade to Symfony 4 and PHPUnit 7 --- .travis.yml | 3 --- composer.json | 24 +++++++++---------- docs/dockers/php7.1/Dockerfile | 2 +- src/Mage.php | 4 ++-- src/MageApplication.php | 6 ++--- .../BuiltIn/Config/DumpCommandTest.php | 2 +- .../Config/EnvironmentsCommandTest.php | 2 +- .../BuiltIn/DeployCommandMiscTasksTest.php | 2 +- .../Command/BuiltIn/DeployCommandMiscTest.php | 2 +- .../BuiltIn/DeployCommandWithReleasesTest.php | 2 +- .../DeployCommandWithoutReleasesTest.php | 2 +- .../BuiltIn/Releases/ListCommandTest.php | 2 +- .../BuiltIn/Releases/RollbackCommandTest.php | 2 +- tests/Command/BuiltIn/VersionCommandTest.php | 2 +- tests/Deploy/StrategyTest.php | 2 +- tests/MageApplicationTest.php | 2 +- tests/Runtime/ProcessMockup.php | 10 ++++++-- tests/Runtime/RuntimeTest.php | 2 +- tests/Task/AbstractTaskTest.php | 2 +- .../Composer/BasicComposerTaskTest.php | 2 +- .../BuiltIn/Composer/SelfUpdateTaskTest.php | 2 +- tests/Task/BuiltIn/ExecTaskTest.php | 2 +- .../BuiltIn/FileSystem/ChangeModeTaskTest.php | 2 +- .../Task/BuiltIn/FileSystem/CopyTaskTest.php | 2 +- .../Task/BuiltIn/FileSystem/LinkTaskTest.php | 2 +- .../Task/BuiltIn/FileSystem/MoveTaskTest.php | 2 +- .../BuiltIn/FileSystem/RemoveTaskTest.php | 2 +- .../BuiltIn/Symfony/AsseticDumpTaskTest.php | 3 ++- tests/Task/TaskFactoryTest.php | 2 +- tests/UtilsTest.php | 2 +- 30 files changed, 51 insertions(+), 47 deletions(-) diff --git a/.travis.yml b/.travis.yml index 51d78aa..1c46773 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,5 @@ language: php php: - - '5.5' - - '5.6' - - '7.0' - '7.1' - '7.2' diff --git a/composer.json b/composer.json index 10ae4de..580533c 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "andres-montanez/magallanes", "description": "The Deployment Tool for PHP Applications", - "homepage": "http://magephp.com", + "homepage": "https://magephp.com", "license": "MIT", "type": "library", "keywords": ["deployment"], @@ -12,17 +12,17 @@ } ], "require": { - "php": ">=5.5.9", - "monolog/monolog": "^1.0", - "symfony/console": "^3.0", - "symfony/filesystem": "^3.0", - "symfony/event-dispatcher": "^3.0", - "symfony/finder": "^3.0", - "symfony/yaml": "^3.0", - "symfony/process": "^3.0" + "php": "^7.1.3", + "monolog/monolog": "~1.11", + "symfony/console": "^4.0", + "symfony/filesystem": "^4.0", + "symfony/event-dispatcher": "^4.0", + "symfony/finder": "^4.0", + "symfony/yaml": "^4.0", + "symfony/process": "^4.0" }, "require-dev": { - "phpunit/phpunit": "4.8.*", + "phpunit/phpunit": "^7.0", "satooshi/php-coveralls": "~1.0" }, "autoload": { @@ -38,8 +38,8 @@ "bin": ["bin/mage"], "extra": { "branch-alias": { - "dev-master": "3.0.x-dev", - "dev-nostromo": "3.x-dev" + "dev-master": "4.0.x-dev", + "dev-discovery-one": "4.x-dev" } } } diff --git a/docs/dockers/php7.1/Dockerfile b/docs/dockers/php7.1/Dockerfile index cb63a2b..53607a2 100644 --- a/docs/dockers/php7.1/Dockerfile +++ b/docs/dockers/php7.1/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:17.10 RUN apt-get update && apt-get upgrade -y RUN apt-get install -y vim curl git unzip -RUN apt-get install -y php7.1-cli php-zip php7.1-curl php7.1-xml +RUN apt-get install -y php7.1-cli php-zip php7.1-curl php7.1-xml php7.1-mbstring RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer diff --git a/src/Mage.php b/src/Mage.php index 78e38d4..f1b6313 100644 --- a/src/Mage.php +++ b/src/Mage.php @@ -17,6 +17,6 @@ namespace Mage; */ class Mage { - const VERSION = '3.4.0'; - const CODENAME = 'Nostromo'; + const VERSION = '4.x'; + const CODENAME = 'Discovery One'; } diff --git a/src/MageApplication.php b/src/MageApplication.php index 77fe4e2..b7b1408 100644 --- a/src/MageApplication.php +++ b/src/MageApplication.php @@ -17,7 +17,7 @@ use Symfony\Component\Finder\SplFileInfo; use Monolog\Logger; use Monolog\Handler\StreamHandler; use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\Console\Event\ConsoleExceptionEvent; +use Symfony\Component\Console\Event\ConsoleErrorEvent; use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Application; use Symfony\Component\Yaml\Parser; @@ -46,12 +46,12 @@ class MageApplication extends Application $dispatcher = new EventDispatcher(); $this->setDispatcher($dispatcher); - $dispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) { + $dispatcher->addListener(ConsoleEvents::ERROR, function (ConsoleErrorEvent $event) { $output = $event->getOutput(); $command = $event->getCommand(); $output->writeln(sprintf('Oops, exception thrown while running command %s', $command->getName())); $exitCode = $event->getExitCode(); - $event->setException(new \LogicException('Caught exception', $exitCode, $event->getException())); + $event->setError(new \LogicException('Caught exception', $exitCode, $event->getError())); }); $this->runtime = $this->instantiateRuntime(); diff --git a/tests/Command/BuiltIn/Config/DumpCommandTest.php b/tests/Command/BuiltIn/Config/DumpCommandTest.php index 4eb25a9..d97aec3 100644 --- a/tests/Command/BuiltIn/Config/DumpCommandTest.php +++ b/tests/Command/BuiltIn/Config/DumpCommandTest.php @@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\Config\DumpCommand; use Mage\Command\AbstractCommand; use Mage\Tests\MageApplicationMockup; use Symfony\Component\Console\Tester\CommandTester; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class DumpCommandTest extends TestCase { diff --git a/tests/Command/BuiltIn/Config/EnvironmentsCommandTest.php b/tests/Command/BuiltIn/Config/EnvironmentsCommandTest.php index 58a6600..a52657c 100644 --- a/tests/Command/BuiltIn/Config/EnvironmentsCommandTest.php +++ b/tests/Command/BuiltIn/Config/EnvironmentsCommandTest.php @@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\Config\EnvironmentsCommand; use Mage\Command\AbstractCommand; use Mage\Tests\MageApplicationMockup; use Symfony\Component\Console\Tester\CommandTester; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class EnvironmentsCommandTest extends TestCase { diff --git a/tests/Command/BuiltIn/DeployCommandMiscTasksTest.php b/tests/Command/BuiltIn/DeployCommandMiscTasksTest.php index c8be597..07cc2a2 100644 --- a/tests/Command/BuiltIn/DeployCommandMiscTasksTest.php +++ b/tests/Command/BuiltIn/DeployCommandMiscTasksTest.php @@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\DeployCommand; use Mage\Tests\MageApplicationMockup; use Mage\Command\AbstractCommand; use Symfony\Component\Console\Tester\CommandTester; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class DeployCommandMiscTasksTest extends TestCase { diff --git a/tests/Command/BuiltIn/DeployCommandMiscTest.php b/tests/Command/BuiltIn/DeployCommandMiscTest.php index 8df52ef..0a757b4 100644 --- a/tests/Command/BuiltIn/DeployCommandMiscTest.php +++ b/tests/Command/BuiltIn/DeployCommandMiscTest.php @@ -15,7 +15,7 @@ use Mage\Runtime\Exception\RuntimeException; use Mage\Tests\MageApplicationMockup; use Mage\Command\AbstractCommand; use Symfony\Component\Console\Tester\CommandTester; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class DeployCommandMiscTest extends TestCase { diff --git a/tests/Command/BuiltIn/DeployCommandWithReleasesTest.php b/tests/Command/BuiltIn/DeployCommandWithReleasesTest.php index de3e201..bef4919 100644 --- a/tests/Command/BuiltIn/DeployCommandWithReleasesTest.php +++ b/tests/Command/BuiltIn/DeployCommandWithReleasesTest.php @@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\DeployCommand; use Mage\Command\AbstractCommand; use Mage\Tests\MageApplicationMockup; use Symfony\Component\Console\Tester\CommandTester; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class DeployCommandWithReleasesTest extends TestCase { diff --git a/tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php b/tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php index 1e58531..76262c2 100644 --- a/tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php +++ b/tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php @@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\DeployCommand; use Mage\Command\AbstractCommand; use Mage\Tests\MageApplicationMockup; use Symfony\Component\Console\Tester\CommandTester; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class DeployCommandWithoutReleasesTest extends TestCase { diff --git a/tests/Command/BuiltIn/Releases/ListCommandTest.php b/tests/Command/BuiltIn/Releases/ListCommandTest.php index 0d560cc..8c06412 100644 --- a/tests/Command/BuiltIn/Releases/ListCommandTest.php +++ b/tests/Command/BuiltIn/Releases/ListCommandTest.php @@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\Releases\ListCommand; use Mage\Command\AbstractCommand; use Mage\Tests\MageApplicationMockup; use Symfony\Component\Console\Tester\CommandTester; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class ListCommandTest extends TestCase { diff --git a/tests/Command/BuiltIn/Releases/RollbackCommandTest.php b/tests/Command/BuiltIn/Releases/RollbackCommandTest.php index 778c7a5..17406dd 100644 --- a/tests/Command/BuiltIn/Releases/RollbackCommandTest.php +++ b/tests/Command/BuiltIn/Releases/RollbackCommandTest.php @@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\Releases\RollbackCommand; use Mage\Command\AbstractCommand; use Mage\Tests\MageApplicationMockup; use Symfony\Component\Console\Tester\CommandTester; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class RollbackCommandTest extends TestCase { diff --git a/tests/Command/BuiltIn/VersionCommandTest.php b/tests/Command/BuiltIn/VersionCommandTest.php index 2f83891..239b547 100644 --- a/tests/Command/BuiltIn/VersionCommandTest.php +++ b/tests/Command/BuiltIn/VersionCommandTest.php @@ -15,7 +15,7 @@ use Mage\Command\BuiltIn\VersionCommand; use Mage\Tests\MageApplicationMockup; use Mage\Mage; use Symfony\Component\Console\Tester\CommandTester; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class VersionCommandTest extends TestCase { diff --git a/tests/Deploy/StrategyTest.php b/tests/Deploy/StrategyTest.php index fd3997d..c54beed 100644 --- a/tests/Deploy/StrategyTest.php +++ b/tests/Deploy/StrategyTest.php @@ -15,7 +15,7 @@ use Mage\Deploy\Strategy\RsyncStrategy; use Mage\Runtime\Exception\RuntimeException; use Mage\Runtime\Runtime; use Exception; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class StrategyTest extends TestCase { diff --git a/tests/MageApplicationTest.php b/tests/MageApplicationTest.php index 4694fe1..891cd9d 100644 --- a/tests/MageApplicationTest.php +++ b/tests/MageApplicationTest.php @@ -14,7 +14,7 @@ use Mage\MageApplication; use Mage\Runtime\Exception\RuntimeException; use Symfony\Component\Console\Tester\ApplicationTester; use Exception; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class MageApplicationTest extends TestCase { diff --git a/tests/Runtime/ProcessMockup.php b/tests/Runtime/ProcessMockup.php index f5b862b..e6d1fa6 100644 --- a/tests/Runtime/ProcessMockup.php +++ b/tests/Runtime/ProcessMockup.php @@ -19,7 +19,7 @@ class ProcessMockup extends Process protected $timeout; protected $success = true; - public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array()) + public function __construct($commandline, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60) { $this->commandline = $commandline; } @@ -29,7 +29,7 @@ class ProcessMockup extends Process $this->timeout = $timeout; } - public function run($callback = null) + public function run(callable $callback = null, array $env = array()): int { if (in_array($this->commandline, $this->forceFail)) { $this->success = false; @@ -50,6 +50,12 @@ class ProcessMockup extends Process if ($this->commandline == 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@hostdemo2 "ls -1 /var/www/test/releases"') { $this->success = false; } + + if (!$this->success) { + return 10; + } + + return 0; } public function isSuccessful() diff --git a/tests/Runtime/RuntimeTest.php b/tests/Runtime/RuntimeTest.php index cb1ccd9..02b43f9 100644 --- a/tests/Runtime/RuntimeTest.php +++ b/tests/Runtime/RuntimeTest.php @@ -15,7 +15,7 @@ use Mage\Runtime\Runtime; use Exception; use Monolog\Logger; use Monolog\Handler\TestHandler; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; use Psr\Log\LogLevel; use Symfony\Component\Process\Process; use DateTime; diff --git a/tests/Task/AbstractTaskTest.php b/tests/Task/AbstractTaskTest.php index e18da77..595ac41 100644 --- a/tests/Task/AbstractTaskTest.php +++ b/tests/Task/AbstractTaskTest.php @@ -12,7 +12,7 @@ namespace Mage\Tests\Task; use Mage\Task\Exception\ErrorException; use Exception; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class AbstractTaskTest extends TestCase { diff --git a/tests/Task/BuiltIn/Composer/BasicComposerTaskTest.php b/tests/Task/BuiltIn/Composer/BasicComposerTaskTest.php index f8f63ac..6c1adc9 100644 --- a/tests/Task/BuiltIn/Composer/BasicComposerTaskTest.php +++ b/tests/Task/BuiltIn/Composer/BasicComposerTaskTest.php @@ -3,7 +3,7 @@ namespace Mage\Tests\Task\BuiltIn\Composer; use Mage\Tests\Runtime\RuntimeMockup; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class BasicComposerTaskTest extends TestCase { diff --git a/tests/Task/BuiltIn/Composer/SelfUpdateTaskTest.php b/tests/Task/BuiltIn/Composer/SelfUpdateTaskTest.php index 1721e8b..880dec7 100644 --- a/tests/Task/BuiltIn/Composer/SelfUpdateTaskTest.php +++ b/tests/Task/BuiltIn/Composer/SelfUpdateTaskTest.php @@ -6,7 +6,7 @@ use Mage\Tests\Runtime\RuntimeMockup; use Mage\Task\BuiltIn\Composer\SelfUpdateTask; use Mage\Task\Exception\SkipException; use Exception; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class SelfUpdateTaskTest extends TestCase { diff --git a/tests/Task/BuiltIn/ExecTaskTest.php b/tests/Task/BuiltIn/ExecTaskTest.php index d548176..c500ad0 100644 --- a/tests/Task/BuiltIn/ExecTaskTest.php +++ b/tests/Task/BuiltIn/ExecTaskTest.php @@ -14,7 +14,7 @@ use Mage\Task\Exception\ErrorException; use Mage\Task\BuiltIn\ExecTask; use Exception; use Mage\Tests\Runtime\RuntimeMockup; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class ExecTest extends TestCase { diff --git a/tests/Task/BuiltIn/FileSystem/ChangeModeTaskTest.php b/tests/Task/BuiltIn/FileSystem/ChangeModeTaskTest.php index 79db322..2456502 100644 --- a/tests/Task/BuiltIn/FileSystem/ChangeModeTaskTest.php +++ b/tests/Task/BuiltIn/FileSystem/ChangeModeTaskTest.php @@ -14,7 +14,7 @@ use Mage\Task\Exception\ErrorException; use Mage\Task\BuiltIn\FS\ChangeModeTask; use Exception; use Mage\Tests\Runtime\RuntimeMockup; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class ChangeModeTest extends TestCase { diff --git a/tests/Task/BuiltIn/FileSystem/CopyTaskTest.php b/tests/Task/BuiltIn/FileSystem/CopyTaskTest.php index 1d91d1a..0242b97 100644 --- a/tests/Task/BuiltIn/FileSystem/CopyTaskTest.php +++ b/tests/Task/BuiltIn/FileSystem/CopyTaskTest.php @@ -14,7 +14,7 @@ use Mage\Task\Exception\ErrorException; use Mage\Task\BuiltIn\FS\CopyTask; use Exception; use Mage\Tests\Runtime\RuntimeMockup; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class CopyTaskTest extends TestCase { diff --git a/tests/Task/BuiltIn/FileSystem/LinkTaskTest.php b/tests/Task/BuiltIn/FileSystem/LinkTaskTest.php index 5869709..f7bd858 100644 --- a/tests/Task/BuiltIn/FileSystem/LinkTaskTest.php +++ b/tests/Task/BuiltIn/FileSystem/LinkTaskTest.php @@ -14,7 +14,7 @@ use Mage\Task\Exception\ErrorException; use Mage\Task\BuiltIn\FS\LinkTask; use Exception; use Mage\Tests\Runtime\RuntimeMockup; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class LinkTaskTest extends TestCase { diff --git a/tests/Task/BuiltIn/FileSystem/MoveTaskTest.php b/tests/Task/BuiltIn/FileSystem/MoveTaskTest.php index 4fdab3d..fb8cea6 100644 --- a/tests/Task/BuiltIn/FileSystem/MoveTaskTest.php +++ b/tests/Task/BuiltIn/FileSystem/MoveTaskTest.php @@ -14,7 +14,7 @@ use Mage\Task\Exception\ErrorException; use Mage\Task\BuiltIn\FS\MoveTask; use Exception; use Mage\Tests\Runtime\RuntimeMockup; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class MoveTaskTest extends TestCase { diff --git a/tests/Task/BuiltIn/FileSystem/RemoveTaskTest.php b/tests/Task/BuiltIn/FileSystem/RemoveTaskTest.php index 4b050a4..1b2a0ad 100644 --- a/tests/Task/BuiltIn/FileSystem/RemoveTaskTest.php +++ b/tests/Task/BuiltIn/FileSystem/RemoveTaskTest.php @@ -14,7 +14,7 @@ use Mage\Task\Exception\ErrorException; use Mage\Task\BuiltIn\FS\RemoveTask; use Exception; use Mage\Tests\Runtime\RuntimeMockup; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class RemoveTaskTest extends TestCase { diff --git a/tests/Task/BuiltIn/Symfony/AsseticDumpTaskTest.php b/tests/Task/BuiltIn/Symfony/AsseticDumpTaskTest.php index e1f694e..357cebf 100644 --- a/tests/Task/BuiltIn/Symfony/AsseticDumpTaskTest.php +++ b/tests/Task/BuiltIn/Symfony/AsseticDumpTaskTest.php @@ -5,8 +5,9 @@ namespace Mage\tests\Task\BuiltIn\Symfony; use Mage\Task\BuiltIn\Symfony\AsseticDumpTask; use Mage\Tests\Runtime\RuntimeMockup; +use PHPUnit\Framework\TestCase; -class AsseticDumpTaskTest extends \PHPUnit_Framework_TestCase +class AsseticDumpTaskTest extends TestCase { /** * @var RuntimeMockup diff --git a/tests/Task/TaskFactoryTest.php b/tests/Task/TaskFactoryTest.php index 110c4f0..0698669 100644 --- a/tests/Task/TaskFactoryTest.php +++ b/tests/Task/TaskFactoryTest.php @@ -17,7 +17,7 @@ use Mage\Runtime\Runtime; use Mage\Runtime\Exception\RuntimeException; use Exception; use Mage\Tests\MageApplicationMockup; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Tester\CommandTester; class TaskFactoryTest extends TestCase diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index 0790a9d..8a62543 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php @@ -13,7 +13,7 @@ namespace Mage\Tests; use Mage\Utils; use Mage\Runtime\Runtime; use DateTime; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; class UtilsTest extends TestCase {