Boot filesystems for a specified domain

This commit is contained in:
bertillon clement
2012-10-10 17:32:37 +02:00
parent 790652531f
commit 237055ef01
8 changed files with 252 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
namespace Knp\Bundle\GaufretteBundle\Tests\Functional;
use Symfony\Component\Filesystem\Filesystem;
use Gaufrette\StreamWrapper;
class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
@@ -90,4 +91,85 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
$this->assertInstanceOf('Gaufrette\Adapter\Ftp', $this->kernel->getContainer()->get('ftp_filesystem')->getAdapter());
}
/**
* @test
*/
public function shouldAllowToNotConfigureStreamWrapper()
{
$this->assertFalse($this->kernel->getContainer()->hasParameter('knp_gaufrette.stream_wrapper.protocol'));
}
/**
* @test
*/
public function shouldConfigureStreamWrapperWithDefaultValues()
{
$kernel = new TestKernel('wrapper_1', false);
$kernel->boot();
$container = $kernel->getContainer();
$this->assertTrue($container->hasParameter('knp_gaufrette.stream_wrapper.protocol'));
$this->assertEquals('gaufrette', $container->getParameter('knp_gaufrette.stream_wrapper.protocol'));
$wrapperFsMap = StreamWrapper::getFilesystemMap();
$fileSystems = $this->kernel->getContainer()->get('knp_gaufrette.filesystem_map');
foreach($fileSystems as $fs) {
$this->assertTrue($wrapperFsMap->has($fs));
}
}
/**
* @test
*/
public function shouldAllowToDefineProtocolOfStreamWrapper()
{
$kernel = new TestKernel('wrapper_2', false);
$kernel->boot();
$container = $kernel->getContainer();
$this->assertTrue($container->hasParameter('knp_gaufrette.stream_wrapper.protocol'));
$this->assertEquals('tada', $container->getParameter('knp_gaufrette.stream_wrapper.protocol'));
}
/**
* @test
*/
public function shouldAllowToDefineWhichFileSystemsShouldBeAddToStreamWrapper()
{
$kernel = new TestKernel('wrapper_2', false);
$kernel->boot();
$container = $kernel->getContainer();
$fileSystems = $container->getParameter('knp_gaufrette.stream_wrapper.filesystems');
$this->assertEquals(array('pictures' => 'cache', 'text' => 'ftp'), $fileSystems);
$wrapperFsMap = StreamWrapper::getFilesystemMap();
foreach($fileSystems as $key => $fs) {
$this->assertTrue($wrapperFsMap->has($key));
}
}
/**
* @test
*/
public function shouldAllowToDefineFileSystemsWithoutDomain()
{
$kernel = new TestKernel('wrapper_3', false);
$kernel->boot();
$container = $kernel->getContainer();
$fileSystems = $container->getParameter('knp_gaufrette.stream_wrapper.filesystems');
$this->assertTrue($container->hasParameter('knp_gaufrette.stream_wrapper.protocol'));
$this->assertEquals('tada', $container->getParameter('knp_gaufrette.stream_wrapper.protocol'));
$this->assertEquals(array('cache' => 'cache', 'ftp' => 'ftp'), $fileSystems);
$wrapperFsMap = StreamWrapper::getFilesystemMap();
foreach($fileSystems as $key => $fs) {
$this->assertTrue($wrapperFsMap->has($key));
}
}
}

View File

@@ -0,0 +1,5 @@
imports:
- { resource: config.yml }
knp_gaufrette:
stream_wrapper: ~

View File

@@ -0,0 +1,9 @@
imports:
- { resource: config.yml }
knp_gaufrette:
stream_wrapper:
protocol: tada
filesystems:
pictures: cache
text: ftp

View File

@@ -0,0 +1,9 @@
imports:
- { resource: config.yml }
knp_gaufrette:
stream_wrapper:
protocol: tada
filesystems:
- cache
- ftp