From 6607a5b9760554b00dda0fddf098e17b54dedb14 Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Fri, 7 Dec 2018 16:08:55 +0400 Subject: [PATCH 01/11] add php 7.1 in travis test --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b00f14c..5c41f01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ php: - 5.5 - 5.6 - 7.0 + - 7.1 env: PREFER_LOWEST="" From d4e9832c6b74009dc1487dfc1fc74af61f351cb1 Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Tue, 11 Dec 2018 18:17:28 +0400 Subject: [PATCH 02/11] class Symfony\Component\Process\ProcessBuilder deprecated use Process instead --- src/Adapter/AbstractBinaryAdapter.php | 2 +- src/ProcessBuilder/ProcessBuilder.php | 95 +++++++++++++++++++ src/ProcessBuilder/ProcessBuilderFactory.php | 3 +- .../ProcessBuilderFactoryInterface.php | 1 - .../ProcessBuilderInterface.php | 42 ++++++++ .../BSDTar/BSDTarAdapterWithOptionsTest.php | 14 +-- .../Adapter/BSDTar/TarBSDTarAdapterTest.php | 16 ++-- .../GNUTar/GNUTarAdapterWithOptionsTest.php | 14 +-- .../Adapter/GNUTar/TarGNUTarAdapterTest.php | 16 ++-- .../AbstractTarVersionProbeTest.php | 2 +- .../VersionProbe/ZipVersionProbeTest.php | 8 +- tests/Tests/Adapter/ZipAdapterTest.php | 18 ++-- 12 files changed, 183 insertions(+), 48 deletions(-) create mode 100644 src/ProcessBuilder/ProcessBuilder.php create mode 100644 src/ProcessBuilder/ProcessBuilderInterface.php diff --git a/src/Adapter/AbstractBinaryAdapter.php b/src/Adapter/AbstractBinaryAdapter.php index 4ed40db..2c7d96c 100644 --- a/src/Adapter/AbstractBinaryAdapter.php +++ b/src/Adapter/AbstractBinaryAdapter.php @@ -18,11 +18,11 @@ use Alchemy\Zippy\Exception\InvalidArgumentException; use Alchemy\Zippy\Parser\ParserFactory; use Alchemy\Zippy\Parser\ParserInterface; +use Alchemy\Zippy\ProcessBuilder\ProcessBuilder; use Alchemy\Zippy\ProcessBuilder\ProcessBuilderFactory; use Alchemy\Zippy\ProcessBuilder\ProcessBuilderFactoryInterface; use Alchemy\Zippy\Resource\ResourceManager; use Symfony\Component\Process\ExecutableFinder; -use Symfony\Component\Process\ProcessBuilder; abstract class AbstractBinaryAdapter extends AbstractAdapter implements BinaryAdapterInterface { diff --git a/src/ProcessBuilder/ProcessBuilder.php b/src/ProcessBuilder/ProcessBuilder.php new file mode 100644 index 0000000..7d416ef --- /dev/null +++ b/src/ProcessBuilder/ProcessBuilder.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Alchemy\Zippy\ProcessBuilder; + +use Symfony\Component\Process\Process; + +class ProcessBuilder +{ + /** + * The command to run and its arguments listed as separate entries + * + * @var array + */ + private $command; + + /** + * The working directory or null to use the working dir of the current PHP process + * + * @var string + */ + private $cwd; + + /** + * ProcessBuilder constructor. + * @param array $command + */ + public function __construct(array $command) + { + $this->command = $command; + $this->cwd = null; + } + + /** + * Creates a Process instance and returns it + * + * @return Process + */ + public function getProcess() + { + $process = new Process($this->command, $this->cwd); + $process->setTimeout(null); + + return $process; + } + + /** + * Adds an argument to the command string + * + * @param string $argument + * + * @return ProcessBuilder + */ + public function add(string $argument) + { + $this->command = array_merge($this->command, array($argument)); + + return $this; + } + + /** + * Sets the working directory + * + * @param string $directory + * + * @return ProcessBuilder + */ + public function setWorkingDirectory(string $directory) + { + $this->cwd = $directory; + + return $this; + } + + /** + * The command to run or a binary path and its arguments listed as separate entries + * + * @param array $command + * + * @return static + */ + public static function create(array $command) + { + return new static($command); + } + +} diff --git a/src/ProcessBuilder/ProcessBuilderFactory.php b/src/ProcessBuilder/ProcessBuilderFactory.php index 0caaf6a..84755f9 100644 --- a/src/ProcessBuilder/ProcessBuilderFactory.php +++ b/src/ProcessBuilder/ProcessBuilderFactory.php @@ -12,7 +12,6 @@ namespace Alchemy\Zippy\ProcessBuilder; use Alchemy\Zippy\Exception\InvalidArgumentException; -use Symfony\Component\Process\ProcessBuilder; class ProcessBuilderFactory implements ProcessBuilderFactoryInterface { @@ -66,6 +65,6 @@ public function create() throw new InvalidArgumentException('No binary set'); } - return ProcessBuilder::create(array($this->binary))->setTimeout(null); + return ProcessBuilder::create(array($this->binary)); } } diff --git a/src/ProcessBuilder/ProcessBuilderFactoryInterface.php b/src/ProcessBuilder/ProcessBuilderFactoryInterface.php index a93e5a8..94c4083 100644 --- a/src/ProcessBuilder/ProcessBuilderFactoryInterface.php +++ b/src/ProcessBuilder/ProcessBuilderFactoryInterface.php @@ -12,7 +12,6 @@ namespace Alchemy\Zippy\ProcessBuilder; use Alchemy\Zippy\Exception\InvalidArgumentException; -use Symfony\Component\Process\ProcessBuilder; interface ProcessBuilderFactoryInterface { diff --git a/src/ProcessBuilder/ProcessBuilderInterface.php b/src/ProcessBuilder/ProcessBuilderInterface.php new file mode 100644 index 0000000..a054016 --- /dev/null +++ b/src/ProcessBuilder/ProcessBuilderInterface.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Alchemy\Zippy\ProcessBuilder; + +use Symfony\Component\Process\Process; + +interface ProcessBuilderInterface +{ + /** + * Creates a Process instance and returns it + * + * @return Process + */ + public function getProcess(); + + /** + * Adds an argument to the command string + * + * @param string $argument + * + * @return ProcessBuilder + */ + public function add(string $argument); + + /** + * Sets the working directory + * + * @param string $directory + * + * @return ProcessBuilder + */ + public function setWorkingDirectory(string $directory); +} diff --git a/tests/Tests/Adapter/BSDTar/BSDTarAdapterWithOptionsTest.php b/tests/Tests/Adapter/BSDTar/BSDTarAdapterWithOptionsTest.php index 795536e..0b26ddf 100644 --- a/tests/Tests/Adapter/BSDTar/BSDTarAdapterWithOptionsTest.php +++ b/tests/Tests/Adapter/BSDTar/BSDTarAdapterWithOptionsTest.php @@ -90,7 +90,7 @@ public function testNewinstance() public function testCreateNoFiles() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -142,7 +142,7 @@ public function testCreateNoFiles() public function testCreate() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -205,7 +205,7 @@ public function testListMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -250,7 +250,7 @@ public function testAddFile() public function testgetVersion() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -272,7 +272,7 @@ public function testExtract() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -308,7 +308,7 @@ public function testExtractWithExtractDirPrecised() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -366,7 +366,7 @@ public function testRemoveMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) diff --git a/tests/Tests/Adapter/BSDTar/TarBSDTarAdapterTest.php b/tests/Tests/Adapter/BSDTar/TarBSDTarAdapterTest.php index f0f4132..dc7bbeb 100644 --- a/tests/Tests/Adapter/BSDTar/TarBSDTarAdapterTest.php +++ b/tests/Tests/Adapter/BSDTar/TarBSDTarAdapterTest.php @@ -68,7 +68,7 @@ protected function provideSupportedAdapter() public function testCreateNoFiles() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -116,7 +116,7 @@ public function testCreate() { $outputParser = ParserFactory::create(TarBSDTarAdapter::getName()); $manager = $this->getResourceManagerMock(__DIR__, array('lalalalala')); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -168,7 +168,7 @@ public function testListMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -202,7 +202,7 @@ public function testAddFile() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -228,7 +228,7 @@ public function testAddFile() public function testgetVersion() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -250,7 +250,7 @@ public function testExtract() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -280,7 +280,7 @@ public function testExtractWithExtractDirPrecised() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -332,7 +332,7 @@ public function testRemoveMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) diff --git a/tests/Tests/Adapter/GNUTar/GNUTarAdapterWithOptionsTest.php b/tests/Tests/Adapter/GNUTar/GNUTarAdapterWithOptionsTest.php index 9fed8a8..8a44c2f 100644 --- a/tests/Tests/Adapter/GNUTar/GNUTarAdapterWithOptionsTest.php +++ b/tests/Tests/Adapter/GNUTar/GNUTarAdapterWithOptionsTest.php @@ -70,7 +70,7 @@ protected function provideSupportedAdapter() public function testCreateNoFiles() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder @@ -123,7 +123,7 @@ public function testCreateNoFiles() public function testCreate() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -181,7 +181,7 @@ public function testListMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -232,7 +232,7 @@ public function testAddFile() public function testgetVersion() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -254,7 +254,7 @@ public function testExtract() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -290,7 +290,7 @@ public function testExtractWithExtractDirPrecised() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -354,7 +354,7 @@ public function testRemoveMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) diff --git a/tests/Tests/Adapter/GNUTar/TarGNUTarAdapterTest.php b/tests/Tests/Adapter/GNUTar/TarGNUTarAdapterTest.php index 56c5bde..0f7044f 100644 --- a/tests/Tests/Adapter/GNUTar/TarGNUTarAdapterTest.php +++ b/tests/Tests/Adapter/GNUTar/TarGNUTarAdapterTest.php @@ -68,7 +68,7 @@ protected function provideNotSupportedAdapter() public function testCreateNoFiles() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder @@ -115,7 +115,7 @@ public function testCreateNoFiles() public function testCreate() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -165,7 +165,7 @@ public function testListMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -205,7 +205,7 @@ public function testAddFile() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -231,7 +231,7 @@ public function testAddFile() public function testgetVersion() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -253,7 +253,7 @@ public function testExtract() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -289,7 +289,7 @@ public function testExtractWithExtractDirPrecised() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -347,7 +347,7 @@ public function testRemoveMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) diff --git a/tests/Tests/Adapter/VersionProbe/AbstractTarVersionProbeTest.php b/tests/Tests/Adapter/VersionProbe/AbstractTarVersionProbeTest.php index 655218a..dcdb0b5 100644 --- a/tests/Tests/Adapter/VersionProbe/AbstractTarVersionProbeTest.php +++ b/tests/Tests/Adapter/VersionProbe/AbstractTarVersionProbeTest.php @@ -56,7 +56,7 @@ public function provideInvalidVersions() protected function getBuilder($version, $call = true) { - $mock = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mock = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockBuilder = $mock ->expects($call ? $this->once() : $this->never()) diff --git a/tests/Tests/Adapter/VersionProbe/ZipVersionProbeTest.php b/tests/Tests/Adapter/VersionProbe/ZipVersionProbeTest.php index ba60a5b..90413c5 100644 --- a/tests/Tests/Adapter/VersionProbe/ZipVersionProbeTest.php +++ b/tests/Tests/Adapter/VersionProbe/ZipVersionProbeTest.php @@ -13,7 +13,7 @@ class ZipVersionProbeTest extends TestCase */ public function testGetStatusIsOk() { - $mockedProcessBuilderInflator = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilderInflator = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilderInflator ->expects($this->once()) @@ -50,7 +50,7 @@ public function testGetStatusIsOk() -e encrypt -n don\'t compress these suffixes -h2 show more help')); - $mockedProcessBuilderDeflator = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilderDeflator = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilderDeflator ->expects($this->once()) @@ -100,7 +100,7 @@ public function testGetStatusIsOk() */ public function testGetStatusIsNotOk() { - $mockedProcessBuilderInflator = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilderInflator = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilderInflator ->expects($this->once()) @@ -117,7 +117,7 @@ public function testGetStatusIsNotOk() ->method('getOutput') ->will($this->returnValue('bsdtar 2.8.3 - libarchive 2.8.3')); - $mockedProcessBuilderDeflator = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilderDeflator = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilderDeflator ->expects($this->once()) diff --git a/tests/Tests/Adapter/ZipAdapterTest.php b/tests/Tests/Adapter/ZipAdapterTest.php index 67535da..e30d9a5 100644 --- a/tests/Tests/Adapter/ZipAdapterTest.php +++ b/tests/Tests/Adapter/ZipAdapterTest.php @@ -70,7 +70,7 @@ protected function provideSupportedAdapter() */ public function testCreateNoFiles() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $this->adapter->setInflator($this->getMockedProcessBuilderFactory($mockedProcessBuilder)); @@ -79,7 +79,7 @@ public function testCreateNoFiles() public function testCreate() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -138,7 +138,7 @@ public function testListMembers() $resource = $this->getResource(self::$zipFile); $archive = $this->adapter->open($resource); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -166,7 +166,7 @@ public function testAddFile() { $resource = $this->getResource(self::$zipFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -198,7 +198,7 @@ public function testAddFile() public function testgetInflatorVersion() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -219,7 +219,7 @@ public function testgetInflatorVersion() public function testgetDeflatorVersion() { - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -242,7 +242,7 @@ public function testRemoveMembers() { $resource = $this->getResource(self::$zipFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -292,7 +292,7 @@ public function testExtract() { $resource = $this->getResource(self::$zipFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -322,7 +322,7 @@ public function testExtractWithExtractDirPrecised() { $resource = $this->getResource(self::$zipFile); - $mockedProcessBuilder = $this->getMockBuilder('\Symfony\Component\Process\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); $mockedProcessBuilder ->expects($this->at(0)) From 0800e139d5755fd8397d53b929a8228428f39efc Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Tue, 11 Dec 2018 18:33:54 +0400 Subject: [PATCH 03/11] use type String --- src/ProcessBuilder/ProcessBuilder.php | 11 ++++++----- src/ProcessBuilder/ProcessBuilderInterface.php | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ProcessBuilder/ProcessBuilder.php b/src/ProcessBuilder/ProcessBuilder.php index 7d416ef..51972b4 100644 --- a/src/ProcessBuilder/ProcessBuilder.php +++ b/src/ProcessBuilder/ProcessBuilder.php @@ -11,9 +11,10 @@ namespace Alchemy\Zippy\ProcessBuilder; +use phpDocumentor\Reflection\Types\String_; use Symfony\Component\Process\Process; -class ProcessBuilder +class ProcessBuilder implements ProcessBuilderInterface { /** * The command to run and its arguments listed as separate entries @@ -55,11 +56,11 @@ public function getProcess() /** * Adds an argument to the command string * - * @param string $argument + * @param String_ $argument * * @return ProcessBuilder */ - public function add(string $argument) + public function add(String_ $argument) { $this->command = array_merge($this->command, array($argument)); @@ -69,11 +70,11 @@ public function add(string $argument) /** * Sets the working directory * - * @param string $directory + * @param String_ $directory * * @return ProcessBuilder */ - public function setWorkingDirectory(string $directory) + public function setWorkingDirectory(String_ $directory) { $this->cwd = $directory; diff --git a/src/ProcessBuilder/ProcessBuilderInterface.php b/src/ProcessBuilder/ProcessBuilderInterface.php index a054016..dc433f5 100644 --- a/src/ProcessBuilder/ProcessBuilderInterface.php +++ b/src/ProcessBuilder/ProcessBuilderInterface.php @@ -11,6 +11,7 @@ namespace Alchemy\Zippy\ProcessBuilder; +use phpDocumentor\Reflection\Types\String_; use Symfony\Component\Process\Process; interface ProcessBuilderInterface @@ -25,18 +26,18 @@ public function getProcess(); /** * Adds an argument to the command string * - * @param string $argument + * @param String_ $argument * * @return ProcessBuilder */ - public function add(string $argument); + public function add(String_ $argument); /** * Sets the working directory * - * @param string $directory + * @param String_ $directory * * @return ProcessBuilder */ - public function setWorkingDirectory(string $directory); + public function setWorkingDirectory(String_ $directory); } From 2d7cbc566621d1c2eee3dae689b5ad6e33258004 Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Tue, 11 Dec 2018 18:39:18 +0400 Subject: [PATCH 04/11] update ProcessBuilder conctruct --- src/ProcessBuilder/ProcessBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ProcessBuilder/ProcessBuilder.php b/src/ProcessBuilder/ProcessBuilder.php index 51972b4..e74adda 100644 --- a/src/ProcessBuilder/ProcessBuilder.php +++ b/src/ProcessBuilder/ProcessBuilder.php @@ -34,7 +34,7 @@ class ProcessBuilder implements ProcessBuilderInterface * ProcessBuilder constructor. * @param array $command */ - public function __construct(array $command) + public function __construct($command) { $this->command = $command; $this->cwd = null; From 45ff667fd776c0b827670092c8621e01962ec033 Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Wed, 12 Dec 2018 10:05:32 +0400 Subject: [PATCH 05/11] disable mock constuctor --- .../BSDTar/BSDTarAdapterWithOptionsTest.php | 28 +++++++++++---- .../Adapter/BSDTar/TarBSDTarAdapterTest.php | 32 ++++++++++++----- .../GNUTar/GNUTarAdapterWithOptionsTest.php | 28 +++++++++++---- .../Adapter/GNUTar/TarGNUTarAdapterTest.php | 32 ++++++++++++----- .../AbstractTarVersionProbeTest.php | 4 ++- .../VersionProbe/ZipVersionProbeTest.php | 16 ++++++--- tests/Tests/Adapter/ZipAdapterTest.php | 36 ++++++++++++++----- 7 files changed, 132 insertions(+), 44 deletions(-) diff --git a/tests/Tests/Adapter/BSDTar/BSDTarAdapterWithOptionsTest.php b/tests/Tests/Adapter/BSDTar/BSDTarAdapterWithOptionsTest.php index 0b26ddf..5d24279 100644 --- a/tests/Tests/Adapter/BSDTar/BSDTarAdapterWithOptionsTest.php +++ b/tests/Tests/Adapter/BSDTar/BSDTarAdapterWithOptionsTest.php @@ -90,7 +90,9 @@ public function testNewinstance() public function testCreateNoFiles() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -142,7 +144,9 @@ public function testCreateNoFiles() public function testCreate() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -205,7 +209,9 @@ public function testListMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -250,7 +256,9 @@ public function testAddFile() public function testgetVersion() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -272,7 +280,9 @@ public function testExtract() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -308,7 +318,9 @@ public function testExtractWithExtractDirPrecised() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -366,7 +378,9 @@ public function testRemoveMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) diff --git a/tests/Tests/Adapter/BSDTar/TarBSDTarAdapterTest.php b/tests/Tests/Adapter/BSDTar/TarBSDTarAdapterTest.php index dc7bbeb..8165ec3 100644 --- a/tests/Tests/Adapter/BSDTar/TarBSDTarAdapterTest.php +++ b/tests/Tests/Adapter/BSDTar/TarBSDTarAdapterTest.php @@ -68,7 +68,9 @@ protected function provideSupportedAdapter() public function testCreateNoFiles() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -116,7 +118,9 @@ public function testCreate() { $outputParser = ParserFactory::create(TarBSDTarAdapter::getName()); $manager = $this->getResourceManagerMock(__DIR__, array('lalalalala')); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -168,7 +172,9 @@ public function testListMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -202,7 +208,9 @@ public function testAddFile() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -228,7 +236,9 @@ public function testAddFile() public function testgetVersion() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -250,7 +260,9 @@ public function testExtract() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -280,7 +292,9 @@ public function testExtractWithExtractDirPrecised() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -332,7 +346,9 @@ public function testRemoveMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) diff --git a/tests/Tests/Adapter/GNUTar/GNUTarAdapterWithOptionsTest.php b/tests/Tests/Adapter/GNUTar/GNUTarAdapterWithOptionsTest.php index 8a44c2f..f540ebf 100644 --- a/tests/Tests/Adapter/GNUTar/GNUTarAdapterWithOptionsTest.php +++ b/tests/Tests/Adapter/GNUTar/GNUTarAdapterWithOptionsTest.php @@ -70,7 +70,9 @@ protected function provideSupportedAdapter() public function testCreateNoFiles() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder @@ -123,7 +125,9 @@ public function testCreateNoFiles() public function testCreate() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -181,7 +185,9 @@ public function testListMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -232,7 +238,9 @@ public function testAddFile() public function testgetVersion() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -254,7 +262,9 @@ public function testExtract() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -290,7 +300,9 @@ public function testExtractWithExtractDirPrecised() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -354,7 +366,9 @@ public function testRemoveMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) diff --git a/tests/Tests/Adapter/GNUTar/TarGNUTarAdapterTest.php b/tests/Tests/Adapter/GNUTar/TarGNUTarAdapterTest.php index 0f7044f..379e02e 100644 --- a/tests/Tests/Adapter/GNUTar/TarGNUTarAdapterTest.php +++ b/tests/Tests/Adapter/GNUTar/TarGNUTarAdapterTest.php @@ -68,7 +68,9 @@ protected function provideNotSupportedAdapter() public function testCreateNoFiles() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder @@ -115,7 +117,9 @@ public function testCreateNoFiles() public function testCreate() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -165,7 +169,9 @@ public function testListMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -205,7 +211,9 @@ public function testAddFile() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -231,7 +239,9 @@ public function testAddFile() public function testgetVersion() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -253,7 +263,9 @@ public function testExtract() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -289,7 +301,9 @@ public function testExtractWithExtractDirPrecised() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -347,7 +361,9 @@ public function testRemoveMembers() { $resource = $this->getResource(self::$tarFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) diff --git a/tests/Tests/Adapter/VersionProbe/AbstractTarVersionProbeTest.php b/tests/Tests/Adapter/VersionProbe/AbstractTarVersionProbeTest.php index dcdb0b5..13c9241 100644 --- a/tests/Tests/Adapter/VersionProbe/AbstractTarVersionProbeTest.php +++ b/tests/Tests/Adapter/VersionProbe/AbstractTarVersionProbeTest.php @@ -56,7 +56,9 @@ public function provideInvalidVersions() protected function getBuilder($version, $call = true) { - $mock = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mock = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockBuilder = $mock ->expects($call ? $this->once() : $this->never()) diff --git a/tests/Tests/Adapter/VersionProbe/ZipVersionProbeTest.php b/tests/Tests/Adapter/VersionProbe/ZipVersionProbeTest.php index 90413c5..6ce017f 100644 --- a/tests/Tests/Adapter/VersionProbe/ZipVersionProbeTest.php +++ b/tests/Tests/Adapter/VersionProbe/ZipVersionProbeTest.php @@ -13,7 +13,9 @@ class ZipVersionProbeTest extends TestCase */ public function testGetStatusIsOk() { - $mockedProcessBuilderInflator = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilderInflator = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilderInflator ->expects($this->once()) @@ -50,7 +52,9 @@ public function testGetStatusIsOk() -e encrypt -n don\'t compress these suffixes -h2 show more help')); - $mockedProcessBuilderDeflator = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilderDeflator = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilderDeflator ->expects($this->once()) @@ -100,7 +104,9 @@ public function testGetStatusIsOk() */ public function testGetStatusIsNotOk() { - $mockedProcessBuilderInflator = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilderInflator = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilderInflator ->expects($this->once()) @@ -117,7 +123,9 @@ public function testGetStatusIsNotOk() ->method('getOutput') ->will($this->returnValue('bsdtar 2.8.3 - libarchive 2.8.3')); - $mockedProcessBuilderDeflator = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilderDeflator = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilderDeflator ->expects($this->once()) diff --git a/tests/Tests/Adapter/ZipAdapterTest.php b/tests/Tests/Adapter/ZipAdapterTest.php index e30d9a5..397c315 100644 --- a/tests/Tests/Adapter/ZipAdapterTest.php +++ b/tests/Tests/Adapter/ZipAdapterTest.php @@ -70,7 +70,9 @@ protected function provideSupportedAdapter() */ public function testCreateNoFiles() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $this->adapter->setInflator($this->getMockedProcessBuilderFactory($mockedProcessBuilder)); @@ -79,7 +81,9 @@ public function testCreateNoFiles() public function testCreate() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -138,7 +142,9 @@ public function testListMembers() $resource = $this->getResource(self::$zipFile); $archive = $this->adapter->open($resource); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -166,7 +172,9 @@ public function testAddFile() { $resource = $this->getResource(self::$zipFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -198,7 +206,9 @@ public function testAddFile() public function testgetInflatorVersion() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -219,7 +229,9 @@ public function testgetInflatorVersion() public function testgetDeflatorVersion() { - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -242,7 +254,9 @@ public function testRemoveMembers() { $resource = $this->getResource(self::$zipFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -292,7 +306,9 @@ public function testExtract() { $resource = $this->getResource(self::$zipFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) @@ -322,7 +338,9 @@ public function testExtractWithExtractDirPrecised() { $resource = $this->getResource(self::$zipFile); - $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder')->getMock(); + $mockedProcessBuilder = $this->getMockBuilder('\Alchemy\Zippy\ProcessBuilder\ProcessBuilder') + ->disableOriginalConstructor() + ->getMock(); $mockedProcessBuilder ->expects($this->at(0)) From 40735f3e1267a487b1adfc1a778b0f3d64ca4c35 Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Wed, 12 Dec 2018 10:17:39 +0400 Subject: [PATCH 06/11] change type --- src/ProcessBuilder/ProcessBuilder.php | 22 ++++++++----------- .../ProcessBuilderInterface.php | 12 +++++----- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/ProcessBuilder/ProcessBuilder.php b/src/ProcessBuilder/ProcessBuilder.php index e74adda..6f6378e 100644 --- a/src/ProcessBuilder/ProcessBuilder.php +++ b/src/ProcessBuilder/ProcessBuilder.php @@ -11,7 +11,7 @@ namespace Alchemy\Zippy\ProcessBuilder; -use phpDocumentor\Reflection\Types\String_; +use Alchemy\Zippy\Exception\InvalidArgumentException; use Symfony\Component\Process\Process; class ProcessBuilder implements ProcessBuilderInterface @@ -54,27 +54,23 @@ public function getProcess() } /** - * Adds an argument to the command string - * - * @param String_ $argument - * - * @return ProcessBuilder + * @inheritdoc */ - public function add(String_ $argument) + public function add($argument) { + if (!is_string($argument)) { + throw new InvalidArgumentException('Argument is not a string'); + } + $this->command = array_merge($this->command, array($argument)); return $this; } /** - * Sets the working directory - * - * @param String_ $directory - * - * @return ProcessBuilder + * @inheritdoc */ - public function setWorkingDirectory(String_ $directory) + public function setWorkingDirectory($directory) { $this->cwd = $directory; diff --git a/src/ProcessBuilder/ProcessBuilderInterface.php b/src/ProcessBuilder/ProcessBuilderInterface.php index dc433f5..113be2c 100644 --- a/src/ProcessBuilder/ProcessBuilderInterface.php +++ b/src/ProcessBuilder/ProcessBuilderInterface.php @@ -11,7 +11,7 @@ namespace Alchemy\Zippy\ProcessBuilder; -use phpDocumentor\Reflection\Types\String_; +use Alchemy\Zippy\Exception\InvalidArgumentException; use Symfony\Component\Process\Process; interface ProcessBuilderInterface @@ -26,18 +26,20 @@ public function getProcess(); /** * Adds an argument to the command string * - * @param String_ $argument + * @param string $argument * * @return ProcessBuilder + * + * @throws InvalidArgumentException In case $argument is not a string */ - public function add(String_ $argument); + public function add($argument); /** * Sets the working directory * - * @param String_ $directory + * @param string $directory * * @return ProcessBuilder */ - public function setWorkingDirectory(String_ $directory); + public function setWorkingDirectory($directory); } From be6c4f55596dc6dfec4e923c5411699bc26320be Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Wed, 12 Dec 2018 10:53:38 +0400 Subject: [PATCH 07/11] test --- src/ProcessBuilder/ProcessBuilder.php | 8 ++------ src/ProcessBuilder/ProcessBuilderInterface.php | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/ProcessBuilder/ProcessBuilder.php b/src/ProcessBuilder/ProcessBuilder.php index 6f6378e..81f2d72 100644 --- a/src/ProcessBuilder/ProcessBuilder.php +++ b/src/ProcessBuilder/ProcessBuilder.php @@ -26,7 +26,7 @@ class ProcessBuilder implements ProcessBuilderInterface /** * The working directory or null to use the working dir of the current PHP process * - * @var string + * @var string|null */ private $cwd; @@ -47,7 +47,7 @@ public function __construct($command) */ public function getProcess() { - $process = new Process($this->command, $this->cwd); + $process = new Process($this->command, $this->cwd, null); $process->setTimeout(null); return $process; @@ -58,10 +58,6 @@ public function getProcess() */ public function add($argument) { - if (!is_string($argument)) { - throw new InvalidArgumentException('Argument is not a string'); - } - $this->command = array_merge($this->command, array($argument)); return $this; diff --git a/src/ProcessBuilder/ProcessBuilderInterface.php b/src/ProcessBuilder/ProcessBuilderInterface.php index 113be2c..d185dd4 100644 --- a/src/ProcessBuilder/ProcessBuilderInterface.php +++ b/src/ProcessBuilder/ProcessBuilderInterface.php @@ -29,8 +29,6 @@ public function getProcess(); * @param string $argument * * @return ProcessBuilder - * - * @throws InvalidArgumentException In case $argument is not a string */ public function add($argument); From 9dfc7d4efa41ff3190e1bdb5106d487412b454cd Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Wed, 12 Dec 2018 11:10:30 +0400 Subject: [PATCH 08/11] test --- src/Adapter/VersionProbe/AbstractTarVersionProbe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Adapter/VersionProbe/AbstractTarVersionProbe.php b/src/Adapter/VersionProbe/AbstractTarVersionProbe.php index 4da1c5d..865df0a 100644 --- a/src/Adapter/VersionProbe/AbstractTarVersionProbe.php +++ b/src/Adapter/VersionProbe/AbstractTarVersionProbe.php @@ -46,7 +46,7 @@ public function getStatus() /** @var Process $process */ $process = $builder ->create() - ->add('--version') +// ->add('--version') ->getProcess(); $process->run(); From 86cbea7e9eaafcaac6483e1039ffffd6cbe95603 Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Wed, 12 Dec 2018 11:15:58 +0400 Subject: [PATCH 09/11] test --- src/Adapter/VersionProbe/AbstractTarVersionProbe.php | 2 +- src/ProcessBuilder/ProcessBuilderInterface.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Adapter/VersionProbe/AbstractTarVersionProbe.php b/src/Adapter/VersionProbe/AbstractTarVersionProbe.php index 865df0a..4da1c5d 100644 --- a/src/Adapter/VersionProbe/AbstractTarVersionProbe.php +++ b/src/Adapter/VersionProbe/AbstractTarVersionProbe.php @@ -46,7 +46,7 @@ public function getStatus() /** @var Process $process */ $process = $builder ->create() -// ->add('--version') + ->add('--version') ->getProcess(); $process->run(); diff --git a/src/ProcessBuilder/ProcessBuilderInterface.php b/src/ProcessBuilder/ProcessBuilderInterface.php index d185dd4..5a3653f 100644 --- a/src/ProcessBuilder/ProcessBuilderInterface.php +++ b/src/ProcessBuilder/ProcessBuilderInterface.php @@ -26,7 +26,7 @@ public function getProcess(); /** * Adds an argument to the command string * - * @param string $argument + * @param $argument * * @return ProcessBuilder */ @@ -35,7 +35,7 @@ public function add($argument); /** * Sets the working directory * - * @param string $directory + * @param $directory * * @return ProcessBuilder */ From c5a6ce3e2f2bf5d803d50e651b174ac93f9205c5 Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Wed, 12 Dec 2018 11:32:25 +0400 Subject: [PATCH 10/11] update minimum version of symfony/process --- composer.json | 2 +- src/ProcessBuilder/ProcessBuilder.php | 3 +-- src/ProcessBuilder/ProcessBuilderInterface.php | 5 ++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 0e21e8d..545ce81 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php": ">=5.5", "doctrine/collections": "~1.0", "symfony/filesystem": "^2.0.5 || ^3.0 || ^4.0", - "symfony/process": "^2.1 || ^3.0 || ^4.0", + "symfony/process": "^3.0 || ^4.0", "symfony/polyfill-mbstring": "^1.3" }, "require-dev": { diff --git a/src/ProcessBuilder/ProcessBuilder.php b/src/ProcessBuilder/ProcessBuilder.php index 81f2d72..0683c0a 100644 --- a/src/ProcessBuilder/ProcessBuilder.php +++ b/src/ProcessBuilder/ProcessBuilder.php @@ -11,7 +11,6 @@ namespace Alchemy\Zippy\ProcessBuilder; -use Alchemy\Zippy\Exception\InvalidArgumentException; use Symfony\Component\Process\Process; class ProcessBuilder implements ProcessBuilderInterface @@ -47,7 +46,7 @@ public function __construct($command) */ public function getProcess() { - $process = new Process($this->command, $this->cwd, null); + $process = new Process($this->command, $this->cwd); $process->setTimeout(null); return $process; diff --git a/src/ProcessBuilder/ProcessBuilderInterface.php b/src/ProcessBuilder/ProcessBuilderInterface.php index 5a3653f..92d7bd0 100644 --- a/src/ProcessBuilder/ProcessBuilderInterface.php +++ b/src/ProcessBuilder/ProcessBuilderInterface.php @@ -11,7 +11,6 @@ namespace Alchemy\Zippy\ProcessBuilder; -use Alchemy\Zippy\Exception\InvalidArgumentException; use Symfony\Component\Process\Process; interface ProcessBuilderInterface @@ -26,7 +25,7 @@ public function getProcess(); /** * Adds an argument to the command string * - * @param $argument + * @param string $argument * * @return ProcessBuilder */ @@ -35,7 +34,7 @@ public function add($argument); /** * Sets the working directory * - * @param $directory + * @param string $directory * * @return ProcessBuilder */ From f508fa66a1bbaa52583c403b3e84dc32b2c97855 Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Wed, 12 Dec 2018 11:40:44 +0400 Subject: [PATCH 11/11] minimum version symfony/process --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 545ce81..c6ebe58 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php": ">=5.5", "doctrine/collections": "~1.0", "symfony/filesystem": "^2.0.5 || ^3.0 || ^4.0", - "symfony/process": "^3.0 || ^4.0", + "symfony/process": "^3.4 || ^4.0", "symfony/polyfill-mbstring": "^1.3" }, "require-dev": {