Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
garak committed Jul 8, 2017
1 parent e7a1118 commit 5a5f275
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DependencyInjection/VichUploaderExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private function registerFormTheme(ContainerBuilder $container)
$resources = $container->hasParameter('twig.form.resources') ?
$container->getParameter('twig.form.resources') : [];

$resources[] = '@VichUploader/Form/fields.html.twig';
array_unshift($resources, '@VichUploader/Form/fields.html.twig');
$container->setParameter('twig.form.resources', $resources);
}
}
2 changes: 1 addition & 1 deletion Resources/doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The `UploadableField` annotation has a few options. They are as follows:
* `fileNameProperty`: required, the property that will contain the name of the uploaded file;
* `size`: the property that will contain the size in bytes of the uploaded file;
* `mimeType`: the property that will contain the mime type of the uploaded file;
* `originalName`: the property that will contain the origilal name of the uploaded file.
* `originalName`: the property that will contain the original name of the uploaded file.

**Note**:

Expand Down
22 changes: 21 additions & 1 deletion Tests/DependencyInjection/VichUploaderExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Vich\UploaderBundle\Tests\DependencyInjection;

use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
use Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension;
use Vich\UploaderBundle\DependencyInjection\VichUploaderExtension;

class VichUploaderExtensionTest extends AbstractExtensionTestCase
Expand All @@ -26,6 +27,8 @@ protected function setUp()
parent::setUp();

$this->container->setParameter('kernel.bundles', []);
$this->container->setParameter('kernel.bundles_metadata', []);
$this->container->setParameter('kernel.root_dir', __DIR__.'/../Fixtures/App/app');
$this->container->setParameter('kernel.cache_dir', sys_get_temp_dir());
}

Expand Down Expand Up @@ -80,7 +83,7 @@ public function testMappingsServiceParameterIsSet()
$this->assertContainerBuilderHasParameter('vich_uploader.mappings', $mappings);
}

public function testDbDriverIsntOverriden()
public function testDbDriverIsNotOverridden()
{
$this->load([
'db_driver' => 'propel',
Expand Down Expand Up @@ -122,4 +125,21 @@ public function testListenersCreation()
$this->assertContainerBuilderNotHasService('vich_uploader.listener.clean.profile_common_avatar');
$this->assertContainerBuilderHasService('vich_uploader.listener.remove.profile_common_avatar');
}

public function testFormThemeCorrectlyOverridden()
{
$vichUploaderExtension = new VichUploaderExtension();
$this->container->registerExtension($vichUploaderExtension);

$twigExtension = new TwigExtension();
$this->container->registerExtension($twigExtension);

$twigExtension->load([['form_themes' => ['@Ololo/trololo.html.twig']]], $this->container);
$vichUploaderExtension->load([$this->getMinimalConfiguration()], $this->container);

$this->assertContainerBuilderHasParameter(
'twig.form.resources',
['@VichUploader/Form/fields.html.twig', 'form_div_layout.html.twig', '@Ololo/trololo.html.twig']
);
}
}

0 comments on commit 5a5f275

Please sign in to comment.