Example #1
0
 /**
  * @dataProvider getVersionDataProvider
  */
 public function testGetVersion($versionCmdOutput, $expectedVersion)
 {
     $cmdCallback = function ($shellCmd, array &$output = null) use($versionCmdOutput) {
         $output = array($versionCmdOutput);
         return !empty($shellCmd);
     };
     $this->_cmd->expects($this->once())->method('_execShellCmd')->with($this->stringContains('phpmd'))->will($this->returnCallback($cmdCallback));
     $this->assertEquals($expectedVersion, $this->_cmd->getVersion());
 }
    /**
     * @param string $type
     * @param bool   $verbose
     * @param string $exceptionClass
     * @param string $validTrace
     *
     * @dataProvider getConfigIoForException
     */
    public function testTagWithTransportException($type, $verbose, $exceptionClass, $validTrace)
    {
        /* @var \PHPUnit_Framework_MockObject_MockObject $loader */
        $loader = $this->loader;
        $loader
            ->expects($this->any())
            ->method('load')
            ->will($this->throwException(new $exceptionClass('MESSAGE')));

        $this->lazyLoader = $this->createLazyLoaderConfigured($type, $verbose);
        $package = $this->lazyLoader->load($this->lazyPackage);

        $this->assertFalse($package);

        $filename = $this->assetType->getFilename();
        $validOutput = array('');

        if ($verbose) {
            $validOutput = array(
                'Reading ' . $filename . ' of <info>' . $this->lazyPackage->getName() . '</info> (<comment>' . $this->lazyPackage->getPrettyVersion() . '</comment>)',
                'Importing empty ' . $type . ' ' . $this->lazyPackage->getPrettyVersion() . ' (' . $this->lazyPackage->getVersion() . ')',
                $validTrace,
                '',
            );
        }
        $this->assertSame($validOutput, $this->io->getTraces());

        $packageCache = $this->lazyLoader->load($this->lazyPackage);
        $this->assertFalse($packageCache);
        $this->assertSame($validOutput, $this->io->getTraces());
    }
Example #3
0
 public function testGetPackageCopy()
 {
     $this->initJob([], $this->atLeastOnce());
     $this->package->expects($this->atLeastOnce())->method('getName')->will($this->returnValue('foo/bar'));
     $this->package->expects($this->atLeastOnce())->method('getVersion')->will($this->returnValue('1.0.0'));
     $this->package->expects($this->atLeastOnce())->method('getPrettyVersion')->will($this->returnValue('1'));
     $this->package->expects($this->atLeastOnce())->method('getType')->will($this->returnValue('lib'));
     $copy = $this->job->getPackageCopy();
     // test
     $this->assertInstanceOf('\\Composer\\Package\\Package', $copy);
     $this->assertEquals($this->package->getName(), $copy->getName());
     $this->assertEquals($this->package->getVersion(), $copy->getVersion());
     $this->assertEquals($this->package->getPrettyVersion(), $copy->getPrettyVersion());
     $this->assertEquals($this->package->getType(), $copy->getType());
     $this->assertEquals($this->package->getExtra(), $copy->getExtra());
 }
Example #4
0
 /**
  * @dataProvider getVersionDataProvider
  */
 public function testGetVersion($versionCmdOutput, $expectedVersion)
 {
     $this->_cmd->expects($this->once())->method('_execShellCmd')->with($this->stringContains('phpmd'))->will($this->returnValue($versionCmdOutput));
     $this->assertEquals($expectedVersion, $this->_cmd->getVersion());
 }