public function testCreate() { $mockProcessBuilder = $this->getMock('Symfony\\Component\\Process\\ProcessBuilder'); $mockProcessBuilder->expects($this->at(0))->method('add')->with($this->equalTo('--create'))->will($this->returnSelf()); $mockProcessBuilder->expects($this->at(1))->method('add')->with($this->equalTo(sprintf('--file=%s', self::$tarFile)))->will($this->returnSelf()); $mockProcessBuilder->expects($this->at(2))->method('setWorkingDirectory')->will($this->returnSelf()); $mockProcessBuilder->expects($this->at(3))->method('add')->with($this->equalTo('lalalalala'))->will($this->returnSelf()); $mockProcessBuilder->expects($this->once())->method('getProcess')->will($this->returnValue($this->getSuccessFullMockProcess())); $manager = $this->getResourceManagerMock(__DIR__, array('lalalalala')); $outputParser = ParserFactory::create(TarGNUTarAdapter::getName()); $this->adapter = new TarGNUTarAdapter($outputParser, $manager, $this->getZippyMockBuilder($mockProcessBuilder)); $this->adapter->create(self::$tarFile, array(__FILE__)); }
public function testCreate() { $mockProcessBuilder = $this->getMock('Symfony\\Component\\Process\\ProcessBuilder'); $mockProcessBuilder->expects($this->at(0))->method('add')->with($this->equalTo('-r'))->will($this->returnSelf()); $mockProcessBuilder->expects($this->at(1))->method('add')->with($this->equalTo(self::$zipFile))->will($this->returnSelf()); $mockProcessBuilder->expects($this->at(2))->method('setWorkingDirectory')->will($this->returnSelf()); $mockProcessBuilder->expects($this->at(3))->method('add')->with($this->equalTo('lalala'))->will($this->returnSelf()); $mockProcessBuilder->expects($this->once())->method('getProcess')->will($this->returnValue($this->getSuccessFullMockProcess())); $manager = $this->getResourceManagerMock(__DIR__, array('lalala')); $outputParser = ParserFactory::create(ZipAdapter::getName()); $deflator = $this->getMockBuilder('Alchemy\\Zippy\\ProcessBuilder\\ProcessBuilderFactory')->disableOriginalConstructor()->setMethods(array('useBinary'))->getMock(); $this->adapter = new ZipAdapter($outputParser, $manager, $this->getZippyMockBuilder($mockProcessBuilder), $deflator); $this->adapter->create(self::$zipFile, array(__FILE__)); return self::$zipFile; }
/** * Returns a new instance of the invoked adapter * * @params String|null $inflatorBinaryName The inflator binary name to use * @params String|null $deflatorBinaryName The deflator binary name to use * * @return AbstractBinaryAdapter * * @throws RuntimeException In case object could not be instanciated */ public static function newInstance(ExecutableFinder $finder, ResourceManager $manager, $inflatorBinaryName = null, $deflatorBinaryName = null) { $inflator = $inflatorBinaryName instanceof ProcessBuilderFactoryInterface ? $inflatorBinaryName : self::findABinary($inflatorBinaryName, static::getDefaultInflatorBinaryName(), $finder); $deflator = $deflatorBinaryName instanceof ProcessBuilderFactoryInterface ? $deflatorBinaryName : self::findABinary($deflatorBinaryName, static::getDefaultDeflatorBinaryName(), $finder); try { $outputParser = ParserFactory::create(static::getName()); } catch (InvalidArgumentException $e) { throw new RuntimeException(sprintf('Failed to get a new instance of %s', get_called_class()), $e->getCode(), $e); } if (null === $inflator) { throw new RuntimeException(sprintf('Unable to create the inflator')); } if (null === $deflator) { throw new RuntimeException(sprintf('Unable to create the deflator')); } return new static($outputParser, $manager, $inflator, $deflator); }
/** * Returns a new instance of the invoked adapter * * @params String|null $inflatorBinaryName The inflator binary name to use * @params String|null $deflatorBinaryName The deflator binary name to use * * @return AbstractBinaryAdapter * * @throws RuntimeException In case object could not be instanciated */ public static function newInstance(ResourceManager $manager, $inflatorBinaryName = null, $deflatorBinaryName = null) { $finder = new ExecutableFinder(); $inflator = self::findABinary($inflatorBinaryName, static::getDefaultInflatorBinaryName(), $finder); $deflator = self::findABinary($deflatorBinaryName, static::getDefaultDeflatorBinaryName(), $finder); try { $outputParser = ParserFactory::create(static::getName()); } catch (InvalidArgumentException $e) { throw new RuntimeException(sprintf('Failed to get a new instance of %s', get_called_class()), $e->getCode(), $e); } return new static($outputParser, $manager, $inflator, $deflator); }