/**
  * @param string $src
  *
  * @return Configuration
  */
 private function createConfig($src)
 {
     $configuration = new Configuration($src);
     $configuration->setJsonFile('component.json');
     $configuration->setEndpoint('https://bower.herokuapp.com');
     $configuration->setCache(new FilesystemCache($this->target . '/cache'));
     $configuration->setAssetDirectory($this->filesystem->makePathRelative($this->target . '/components', $src));
     return $configuration;
 }
    /**
     * @covers Sp\BowerBundle\Bower\Configuration::getJson
     */
    public function testGetJsonReturnsObject()
    {
        $config = new Configuration('/foo');
        $config->setDirectory('/test');
        $config->setAssetDirectory('/foo');
        $config->setJsonFile('foo.json');
        $expected = <<<json
{"directory":"..\\/foo\\/","json":"foo.json"}
json;
        $this->assertEquals($expected, $config->getJson());
    }
 public function testUpdate()
 {
     $configuration = new Configuration('/foo');
     $configuration->setAssetDirectory('/test');
     $configuration->setJsonFile('foo.json');
     $barConfig = new Configuration('/bar');
     $bundles = array('DemoBundle' => $configuration, 'AcmeBundle' => $barConfig);
     $this->bower->expects($this->at(0))->method('update')->with($this->equalTo($configuration));
     $this->bower->expects($this->at(1))->method('update')->with($this->equalTo($barConfig));
     $this->bm->expects($this->once())->method('getBundles')->will($this->returnValue($bundles));
     $this->command->run(new ArrayInput(array()), new NullOutput());
 }
 /**
  * @param string $file
  *
  * @return string
  * @throws FileNotFoundException
  */
 private function resolvePath($file)
 {
     $resetDir = getcwd();
     chdir($this->config->getDirectory());
     if (strpos($file, '@') === 0) {
         return $file;
     }
     $extension = pathinfo($file, PATHINFO_EXTENSION);
     if (!file_exists($file) && in_array($extension, $this->requiredExtensions)) {
         throw new FileNotFoundException(sprintf('The required file "%s" could not be found. Did you accidentally deleted the "components" directory?', $file));
     }
     $path = realpath($file) ?: "";
     chdir($resetDir);
     return $path;
 }
Beispiel #5
0
 /**
  * @expectedException \Sp\BowerBundle\Bower\Exception\RuntimeException
  */
 public function testUnsuccessfulInstallThrowsRuntimeException()
 {
     $jsonString = file_get_contents(self::$fixturesDirectory . '/error.json');
     $configDir = "/config_dir";
     $config = new Configuration($configDir);
     $config->setCache($this->cache);
     $this->processBuilder->expects($this->once())->method('getProcess')->will($this->returnValue($this->process));
     $this->process->expects($this->once())->method('isSuccessful')->will($this->returnValue(false));
     $this->process->expects($this->once())->method('getErrorOutput')->will($this->returnValue($jsonString));
     $this->bower->install($config);
 }