/**
  * @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());
 }
Example #4
0
 /**
  * @covers Sp\BowerBundle\Bower\Bower::createDependencyMappingCache
  */
 public function testCreateDependencyMappingCache()
 {
     $configDir = __DIR__ . "/Fixtures/config";
     $jsonFile = 'bower.json';
     $jsonFilePath = $configDir . "/" . $jsonFile;
     $config = new Configuration($configDir);
     $config->setJsonFile($jsonFile);
     $config->setCache($this->cache);
     $jsonDependencyMapping = file_get_contents(self::$fixturesDirectory . '/dependency_mapping.json');
     $arrayDependencyMapping = (require self::$fixturesDirectory . '/dependency_mapping.php');
     $this->processBuilder->expects($this->once())->method('setWorkingDirectory')->with($this->equalTo($configDir));
     $this->processBuilder->expects($this->once())->method('setTimeout')->with($this->equalTo(600));
     $this->processBuilder->expects($this->at(2))->method('add')->with($this->equalTo($this->bin));
     $this->processBuilder->expects($this->at(3))->method('add')->with($this->equalTo('list'));
     $this->processBuilder->expects($this->at(4))->method('add')->with($this->equalTo('--json'));
     $this->processBuilder->expects($this->once())->method('getProcess')->will($this->returnValue($this->process));
     $this->process->expects($this->once())->method('isSuccessful')->will($this->returnValue(true));
     $this->bower->expects($this->once())->method('dumpBowerConfig');
     $this->eventDispatcher->expects($this->at(0))->method('dispatch')->with($this->equalTo(BowerEvents::PRE_EXEC));
     $this->eventDispatcher->expects($this->at(1))->method('dispatch')->with($this->equalTo(BowerEvents::POST_EXEC));
     $this->process->expects($this->once())->method('run')->with($this->equalTo(null));
     $this->process->expects($this->once())->method('getOutput')->will($this->returnValue($jsonDependencyMapping));
     $this->cache->expects($this->once())->method('save')->with($this->equalTo(hash_file('sha1', $jsonFilePath)), $this->equalTo($arrayDependencyMapping));
     $this->bower->createDependencyMappingCache($config);
 }