diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..790714e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +/.* export-ignore +/tests export-ignore +/phpunit.xml.dist export-ignore +/CHANGELOG.md diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..1939ace --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,70 @@ +name: Test + +on: + push: + pull_request: + types: [opened, synchronize, edited, reopened] + +jobs: + test: + name: "PHP ${{ matrix.php-version }}${{ matrix.symfony-process-version != '' && format(' + symfony/process {0}', matrix.symfony-process-version) || '' }}" + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false + matrix: + php-version: + - '5.5' + - '5.6' + - '7.0' + - '7.1' + - '7.2' + - '7.3' + - '7.4' + - '8.0' + - '8.1' + symfony-process-version: [''] + include: + - php-version: '7.0' + symfony-process-version: '2.0' + - php-version: '7.0' + symfony-process-version: '3.0' + - php-version: '7.2' + symfony-process-version: '5.0' + - php-version: '7.3' + symfony-process-version: '5.0' + - php-version: '7.4' + symfony-process-version: '5.0' + - php-version: '8.0' + symfony-process-version: '5.0' + - php-version: '8.0' + symfony-process-version: '6.0' + - php-version: '8.1' + symfony-process-version: '5.0' + - php-version: '8.1' + symfony-process-version: '6.0' + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + coverage: none + ini-values: "memory_limit=-1" + php-version: ${{ matrix.php-version }} + tools: composer:v2 + + - name: Configure Symfony Process + if: ${{ matrix.symfony-process-version != '' }} + run: composer require --no-update "symfony/process:^${{ matrix.symfony-process-version }}" + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Install Simple PHPUnit + run: vendor/bin/simple-phpunit install + + - name: Run PHPUnit + run: vendor/bin/simple-phpunit -v diff --git a/.gitignore b/.gitignore index 3a9875b..2976ea6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /vendor/ -composer.lock +/composer.lock +/.phpunit.result.cache +/.idea diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b95ee4f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: php -dist: trusty - -sudo: false - -php: - - 7.0 - - 7.1 - - 7.2 - - 7.3 - -matrix: - include: - - php: 7.0 - env: COMPOSER_REQUIRE="symfony/process:^2.0" - - php: 7.0 - env: COMPOSER_REQUIRE="symfony/process:^3.0" - - php: 7.2 - env: COMPOSER_REQUIRE="symfony/process:^5.0" - - php: 7.3 - env: COMPOSER_REQUIRE="symfony/process:^5.0" - -before_script: - - composer self-update - - if [ -n "$COMPOSER_REQUIRE" ]; then composer require --no-update $COMPOSER_REQUIRE; fi - - composer update $COMPOSER_OPTIONS diff --git a/README.md b/README.md index 05b3a13..96e27f2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Binary-Driver is a set of PHP tools to build binary drivers. -[![Build Status](https://travis-ci.org/alchemy-fr/BinaryDriver.png?branch=master)](https://travis-ci.org/alchemy-fr/BinaryDriver) +[![Build Status](https://github.com/alchemy-fr/BinaryDriver/actions/workflows/test.yaml/badge.svg)](https://github.com/alchemy-fr/BinaryDriver/actions/workflows/test.yaml) ## Why ? diff --git a/composer.json b/composer.json index a91d6c1..70953af 100644 --- a/composer.json +++ b/composer.json @@ -27,17 +27,22 @@ } ], "require": { - "php" : ">=5.5", - "evenement/evenement" : "^3.0|^2.0|^1.0", - "psr/log" : "^1.0", - "symfony/process" : "^2.3|^3.0|^4.0|^5.0" + "php": ">=5.5", + "evenement/evenement": "^1.0|^2.0|^3.0", + "psr/log": "^1.0|^2.0", + "symfony/process": "^2.3|^3.0|^4.0|^5.0|^6.0" }, "require-dev": { - "phpunit/phpunit" : "^4.0|^5.0" + "symfony/phpunit-bridge": "^5.0" }, "autoload": { "psr-0": { "Alchemy": "src" } + }, + "autoload-dev": { + "psr-4": { + "Alchemy\\Tests\\": "tests/Alchemy" + } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0c043a9..60e6979 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -7,24 +7,24 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="true" verbose="false" bootstrap="tests/bootstrap.php" > + + - + tests - - vendor - tests - + + src/ + diff --git a/src/Alchemy/BinaryDriver/BinaryDriverTestCase.php b/src/Alchemy/BinaryDriver/BinaryDriverTestCase.php index 3d0463d..061c07b 100644 --- a/src/Alchemy/BinaryDriver/BinaryDriverTestCase.php +++ b/src/Alchemy/BinaryDriver/BinaryDriverTestCase.php @@ -2,20 +2,21 @@ namespace Alchemy\BinaryDriver; +use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Symfony\Component\Process\Process; /** * Convenient PHPUnit methods for testing BinaryDriverInterface implementations. */ -class BinaryDriverTestCase extends \PHPUnit_Framework_TestCase +class BinaryDriverTestCase extends TestCase { /** * @return ProcessBuilderFactoryInterface */ public function createProcessBuilderFactoryMock() { - return $this->getMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); + return $this->createMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); } /** @@ -63,7 +64,7 @@ public function createProcessMock($runs = 1, $success = true, $commandLine = nul */ public function createLoggerMock() { - return $this->getMock('Psr\Log\LoggerInterface'); + return $this->createMock('Psr\Log\LoggerInterface'); } /** @@ -71,6 +72,6 @@ public function createLoggerMock() */ public function createConfigurationMock() { - return $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); + return $this->createMock('Alchemy\BinaryDriver\ConfigurationInterface'); } } diff --git a/src/Alchemy/BinaryDriver/Configuration.php b/src/Alchemy/BinaryDriver/Configuration.php index cd0ebbb..4e31966 100644 --- a/src/Alchemy/BinaryDriver/Configuration.php +++ b/src/Alchemy/BinaryDriver/Configuration.php @@ -23,6 +23,7 @@ public function __construct(array $data = array()) /** * {@inheritdoc} */ + #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator($this->data); @@ -76,6 +77,7 @@ public function all() /** * {@inheritdoc} */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return $this->has($offset); @@ -84,6 +86,7 @@ public function offsetExists($offset) /** * {@inheritdoc} */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); @@ -92,6 +95,7 @@ public function offsetGet($offset) /** * {@inheritdoc} */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $this->set($offset, $value); @@ -100,6 +104,7 @@ public function offsetSet($offset, $value) /** * {@inheritdoc} */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { $this->remove($offset); diff --git a/tests/Alchemy/Tests/BinaryDriver/AbstractBinaryTest.php b/tests/Alchemy/Tests/BinaryDriver/AbstractBinaryTest.php index f51ab6f..7c04722 100644 --- a/tests/Alchemy/Tests/BinaryDriver/AbstractBinaryTest.php +++ b/tests/Alchemy/Tests/BinaryDriver/AbstractBinaryTest.php @@ -7,6 +7,7 @@ use Alchemy\BinaryDriver\Configuration; use Alchemy\BinaryDriver\Exception\ExecutableNotFoundException; use Alchemy\BinaryDriver\Listeners\ListenerInterface; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Process\ExecutableFinder; class AbstractBinaryTest extends BinaryDriverTestCase @@ -61,21 +62,21 @@ public function testMultipleLoadWithBinaryName() public function testLoadWithMultiplePathExpectingAFailure() { - $this->setExpectedException(ExecutableNotFoundException::class); + $this->expectException(ExecutableNotFoundException::class); Implementation::load(array('bachibouzouk', 'moribon')); } public function testLoadWithUniquePathExpectingAFailure() { - $this->setExpectedException(ExecutableNotFoundException::class); + $this->expectException(ExecutableNotFoundException::class); Implementation::load('bachibouzouk'); } public function testLoadWithCustomLogger() { - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger = $this->createMock('Psr\Log\LoggerInterface'); $imp = Implementation::load('php', $logger); $this->assertEquals($logger, $imp->getProcessRunner()->getLogger()); @@ -91,7 +92,7 @@ public function testLoadWithCustomConfigurationAsArray() public function testLoadWithCustomConfigurationAsObject() { - $conf = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); + $conf = $this->createMock('Alchemy\BinaryDriver\ConfigurationInterface'); $imp = Implementation::load('php', null, $conf); $this->assertEquals($conf, $imp->getConfiguration()); @@ -100,7 +101,7 @@ public function testLoadWithCustomConfigurationAsObject() public function testProcessBuilderFactoryGetterAndSetters() { $imp = Implementation::load('php'); - $factory = $this->getMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); + $factory = $this->createMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); $imp->setProcessBuilderFactory($factory); $this->assertEquals($factory, $imp->getProcessBuilderFactory()); @@ -109,7 +110,7 @@ public function testProcessBuilderFactoryGetterAndSetters() public function testConfigurationGetterAndSetters() { $imp = Implementation::load('php'); - $conf = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); + $conf = $this->createMock('Alchemy\BinaryDriver\ConfigurationInterface'); $imp->setConfiguration($conf); $this->assertEquals($conf, $imp->getConfiguration()); @@ -132,7 +133,7 @@ public function testTimeoutIsSetOnProcessBuilderSetting() { $imp = Implementation::load('php', null, array('timeout' => 42)); - $factory = $this->getMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); + $factory = $this->createMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); $factory->expects($this->once()) ->method('setTimeout') ->with(42); @@ -148,7 +149,7 @@ public function testListenRegistersAListener() ->disableOriginalConstructor() ->getMock(); - $listener = $this->getMock('Alchemy\BinaryDriver\Listeners\ListenerInterface'); + $listener = $this->createMock('Alchemy\BinaryDriver\Listeners\ListenerInterface'); $listeners->expects($this->once()) ->method('register') @@ -168,8 +169,8 @@ public function testListenRegistersAListener() public function testCommandRunsAProcess($parameters, $bypassErrors, $expectedParameters, $output) { $imp = Implementation::load('php'); - $factory = $this->getMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); - $processRunner = $this->getMock('Alchemy\BinaryDriver\ProcessRunnerInterface'); + $factory = $this->createMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); + $processRunner = $this->createMock('Alchemy\BinaryDriver\ProcessRunnerInterface'); $process = $this->getMockBuilder('Symfony\Component\Process\Process') ->disableOriginalConstructor() @@ -197,8 +198,8 @@ public function testCommandRunsAProcess($parameters, $bypassErrors, $expectedPar public function testCommandWithTemporaryListeners($parameters, $bypassErrors, $expectedParameters, $output, $count, $listeners) { $imp = Implementation::load('php'); - $factory = $this->getMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); - $processRunner = $this->getMock('Alchemy\BinaryDriver\ProcessRunnerInterface'); + $factory = $this->createMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); + $processRunner = $this->createMock('Alchemy\BinaryDriver\ProcessRunnerInterface'); $process = $this->getMockBuilder('Symfony\Component\Process\Process') ->disableOriginalConstructor() @@ -263,7 +264,7 @@ public function testUnlistenUnregistersAListener() ->disableOriginalConstructor() ->getMock(); - $listener = $this->getMock('Alchemy\BinaryDriver\Listeners\ListenerInterface'); + $listener = $this->createMock('Alchemy\BinaryDriver\Listeners\ListenerInterface'); $listeners->expects($this->once()) ->method('unregister') @@ -278,11 +279,11 @@ public function testUnlistenUnregistersAListener() } /** - * @return \PHPUnit_Framework_MockObject_MockObject + * @return MockObject */ private function getMockListener() { - $listener = $this->getMock(ListenerInterface::class); + $listener = $this->createMock(ListenerInterface::class); $listener->expects($this->any()) ->method('forwardedEvents') ->willReturn(array()); diff --git a/tests/Alchemy/Tests/BinaryDriver/AbstractProcessBuilderFactoryTest.php b/tests/Alchemy/Tests/BinaryDriver/AbstractProcessBuilderFactoryTest.php index de0b61c..49529d4 100644 --- a/tests/Alchemy/Tests/BinaryDriver/AbstractProcessBuilderFactoryTest.php +++ b/tests/Alchemy/Tests/BinaryDriver/AbstractProcessBuilderFactoryTest.php @@ -2,10 +2,12 @@ namespace Alchemy\Tests\BinaryDriver; +use Alchemy\BinaryDriver\Exception\InvalidArgumentException; +use PHPUnit\Framework\TestCase; use Symfony\Component\Process\ExecutableFinder; use Alchemy\BinaryDriver\ProcessBuilderFactory; -abstract class AbstractProcessBuilderFactoryTest extends \PHPUnit_Framework_TestCase +abstract class AbstractProcessBuilderFactoryTest extends TestCase { public static $phpBinary; @@ -49,11 +51,10 @@ public function testGetSetBinary() $this->assertEquals($phpUnit, $factory->getBinary()); } - /** - * @expectedException Alchemy\BinaryDriver\Exception\InvalidArgumentException - */ public function testUseNonExistantBinary() { + $this->expectException(InvalidArgumentException::class); + $factory = $this->getProcessBuilderFactory(static::$phpBinary); $factory->useBinary('itissureitdoesnotexist'); } diff --git a/tests/Alchemy/Tests/BinaryDriver/ConfigurationTest.php b/tests/Alchemy/Tests/BinaryDriver/ConfigurationTest.php index b2cd2dd..063539b 100644 --- a/tests/Alchemy/Tests/BinaryDriver/ConfigurationTest.php +++ b/tests/Alchemy/Tests/BinaryDriver/ConfigurationTest.php @@ -3,8 +3,9 @@ namespace Alchemy\Tests\BinaryDriver; use Alchemy\BinaryDriver\Configuration; +use PHPUnit\Framework\TestCase; -class ConfigurationTest extends \PHPUnit_Framework_TestCase +class ConfigurationTest extends TestCase { public function testArrayAccessImplementation() { diff --git a/tests/Alchemy/Tests/BinaryDriver/Listeners/DebugListenerTest.php b/tests/Alchemy/Tests/BinaryDriver/Listeners/DebugListenerTest.php index 6995867..51e6252 100644 --- a/tests/Alchemy/Tests/BinaryDriver/Listeners/DebugListenerTest.php +++ b/tests/Alchemy/Tests/BinaryDriver/Listeners/DebugListenerTest.php @@ -3,9 +3,10 @@ namespace Alchemy\Tests\BinaryDriver\Listeners; use Alchemy\BinaryDriver\Listeners\DebugListener; +use PHPUnit\Framework\TestCase; use Symfony\Component\Process\Process; -class DebugListenerTest extends \PHPUnit_Framework_TestCase +class DebugListenerTest extends TestCase { public function testHandle() { diff --git a/tests/Alchemy/Tests/BinaryDriver/Listeners/ListenersTest.php b/tests/Alchemy/Tests/BinaryDriver/Listeners/ListenersTest.php index fe96d73..62a2d7f 100644 --- a/tests/Alchemy/Tests/BinaryDriver/Listeners/ListenersTest.php +++ b/tests/Alchemy/Tests/BinaryDriver/Listeners/ListenersTest.php @@ -5,8 +5,9 @@ use Alchemy\BinaryDriver\Listeners\Listeners; use Evenement\EventEmitter; use Alchemy\BinaryDriver\Listeners\ListenerInterface; +use PHPUnit\Framework\TestCase; -class ListenersTest extends \PHPUnit_Framework_TestCase +class ListenersTest extends TestCase { public function testRegister() { diff --git a/tests/Alchemy/Tests/BinaryDriver/ProcessRunnerTest.php b/tests/Alchemy/Tests/BinaryDriver/ProcessRunnerTest.php index d350a86..e4b1db8 100644 --- a/tests/Alchemy/Tests/BinaryDriver/ProcessRunnerTest.php +++ b/tests/Alchemy/Tests/BinaryDriver/ProcessRunnerTest.php @@ -64,7 +64,7 @@ public function testRunFailingProcess() $logger = $this->createLoggerMock(); $runner = $this->getProcessRunner($logger); - $process = $this->createProcessMock(1, false, '--helloworld--', null, null, true); + $process = $this->createProcessMock(1, false, '--helloworld--', '', '', true); $logger ->expects($this->once()) @@ -114,7 +114,7 @@ public function testRunfailingProcessBypassingErrors() $logger = $this->createLoggerMock(); $runner = $this->getProcessRunner($logger); - $process = $this->createProcessMock(1, false, '--helloworld--', 'Hello output', null, true); + $process = $this->createProcessMock(1, false, '--helloworld--', 'Hello output', '', true); $logger ->expects($this->once())