Skip to content

Commit

Permalink
Configure web directory. Fixes #242
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Eckerstorfer committed Jun 6, 2014
1 parent bf54df5 commit 2f4af52
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 39 deletions.
11 changes: 1 addition & 10 deletions Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,6 @@ protected function getSrcDir()
*/
protected function getDestDir()
{
$outputDir = $this->getContainer()->getParameter('braincrafted_bootstrap.output_dir');
if (strlen($outputDir) > 0 && '/' !== substr($outputDir, -1)) {
$outputDir .= '/';
}

return sprintf(
'%s/../web/%sfonts',
$this->getContainer()->getParameter('kernel.root_dir'),
$outputDir
);
return $this->getContainer()->getParameter('braincrafted_bootstrap.fonts_dir');
}
}
1 change: 1 addition & 0 deletions DependencyInjection/BraincraftedBootstrapExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function load(array $configs, ContainerBuilder $container)
}
$container->setParameter('braincrafted_bootstrap.assets_dir', $config['assets_dir']);
$container->setParameter('braincrafted_bootstrap.fontawesome_dir', $config['fontawesome_dir']);
$container->setParameter('braincrafted_bootstrap.fonts_dir', $config['fonts_dir']);
$container->setParameter('braincrafted_bootstrap.output_dir', $config['output_dir']);
$container->setParameter('braincrafted_bootstrap.less_filter', $config['less_filter']);
$container->setParameter('braincrafted_bootstrap.icon_prefix', $config['icon_prefix']);
Expand Down
6 changes: 6 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class Configuration implements ConfigurationInterface
/** @var string */
const DEFAULT_JQUERY_PATH = '%kernel.root_dir%/../vendor/jquery/jquery/jquery-1.11.0.js';

/** @var string */
const DEFAULT_FONTS_DIR = '%kernel.root_dir%/../web/fonts';

/**
* {@inheritDoc}
*/
Expand All @@ -71,6 +74,9 @@ private function buildConfigTree()
->scalarNode('jquery_path')
->defaultValue(self::DEFAULT_JQUERY_PATH)
->end()
->scalarNode('fonts_dir')
->defaultValue(self::DEFAULT_FONTS_DIR)
->end()
// TODO for v3.0: Rename to css_preprocessor
->scalarNode('less_filter')
->defaultValue('less')
Expand Down
39 changes: 10 additions & 29 deletions Tests/Command/InstallCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,10 @@ public function tearDown()
*/
public function testExecute()
{
$this->container
->shouldReceive('getParameter')
->with('kernel.root_dir')
->andReturn(__DIR__.'/fixtures/app');
$this->container
->shouldReceive('getParameter')
->with('braincrafted_bootstrap.assets_dir')
->andReturn(__DIR__.'/fixtures/vendor/twbs/bootstrap');
$this->container
->shouldReceive('getParameter')
->with('braincrafted_bootstrap.output_dir')
->andReturn('');
$this->container
->shouldReceive('getParameter')
->with('braincrafted_bootstrap.icon_prefix')
Expand All @@ -74,6 +66,10 @@ public function testExecute()
->shouldReceive('getParameter')
->with('braincrafted_bootstrap.less_filter')
->andReturn('');
$this->container
->shouldReceive('getParameter')
->with('braincrafted_bootstrap.fonts_dir')
->andReturn(__DIR__.'/fixtures/web/fonts');

// mock the Kernel or create one depending on your needs
$application = new Application($this->kernel);
Expand All @@ -95,15 +91,8 @@ public function testExecuteFontAwesome()
{
$this->container
->shouldReceive('getParameter')
->with('kernel.root_dir')
->andReturn(__DIR__.'/fixtures/app');
$this->container
->shouldReceive('getParameter')
->never();
$this->container
->shouldReceive('getParameter')
->with('braincrafted_bootstrap.output_dir')
->andReturn('');
->with('braincrafted_bootstrap.fonts_dir')
->andReturn(__DIR__.'/fixtures/web/fonts');
$this->container
->shouldReceive('getParameter')
->with('braincrafted_bootstrap.icon_prefix')
Expand Down Expand Up @@ -135,18 +124,14 @@ public function testExecuteFontAwesome()
*/
public function testExecuteSrcNotExists()
{
$this->container
->shouldReceive('getParameter')
->with('kernel.root_dir')
->andReturn(__DIR__.'/fixtures/app');
$this->container
->shouldReceive('getParameter')
->with('braincrafted_bootstrap.assets_dir')
->andReturn(__DIR__.'/invalid');
$this->container
->shouldReceive('getParameter')
->with('braincrafted_bootstrap.output_dir')
->andReturn('');
->with('braincrafted_bootstrap.fonts_dir')
->andReturn(__DIR__.'/fixtures/web/fonts');
$this->container
->shouldReceive('getParameter')
->with('braincrafted_bootstrap.icon_prefix')
Expand Down Expand Up @@ -176,12 +161,8 @@ public function testExecuteInvalidDestDirectory()
{
$this->container
->shouldReceive('getParameter')
->with('kernel.root_dir')
->andReturn('/');
$this->container
->shouldReceive('getParameter')
->with('braincrafted_bootstrap.output_dir')
->andReturn('');
->with('braincrafted_bootstrap.fonts_dir')
->andReturn('/../fonts');
$this->container
->shouldReceive('getParameter')
->with('braincrafted_bootstrap.icon_prefix')
Expand Down

0 comments on commit 2f4af52

Please sign in to comment.