Moved and renamed functional tests. Simplified ConfigurationTest
This commit is contained in:
79
Tests/Functional/ConfigurationTest.php
Normal file
79
Tests/Functional/ConfigurationTest.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Knp\Bundle\GaufretteBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Component\HttpKernel\Util\Filesystem;
|
||||
|
||||
class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $cacheDir;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->cacheDir = __DIR__.'/Resources/cache';
|
||||
if (file_exists($this->cacheDir)) {
|
||||
$filesystem = new Filesystem();
|
||||
$filesystem->remove($this->cacheDir);
|
||||
}
|
||||
|
||||
mkdir($this->cacheDir, 0777, true);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
if (file_exists($this->cacheDir)) {
|
||||
$filesystem = new Filesystem();
|
||||
$filesystem->remove($this->cacheDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function shouldAllowForFilesystemAlias()
|
||||
{
|
||||
$kernel = new TestKernel('test', false);
|
||||
$kernel->boot();
|
||||
|
||||
$container = $kernel->getContainer();
|
||||
|
||||
$this->assertInstanceOf('Gaufrette\Filesystem', $container->get('foo_filesystem'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function shouldWorkForOtherEnv()
|
||||
{
|
||||
$kernel = new TestKernel('dev', false);
|
||||
$kernel->boot();
|
||||
|
||||
$container = $kernel->getContainer();
|
||||
$this->assertInstanceOf('Gaufrette\Filesystem', $container->get('foo_filesystem'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function shouldAllowAccessToAllPublicServices()
|
||||
{
|
||||
$kernel = new TestKernel('dev', false);
|
||||
$kernel->boot();
|
||||
|
||||
$container = $kernel->getContainer();
|
||||
$this->assertInstanceOf('Gaufrette\Filesystem', $container->get('foo_filesystem'));
|
||||
$this->assertInstanceOf('Knp\Bundle\GaufretteBundle\FilesystemMap', $container->get('knp_gaufrette.filesystem_map'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function shouldAllowAccessToFilesystemThoughFilesystemMap()
|
||||
{
|
||||
$kernel = new TestKernel('test', false);
|
||||
$kernel->boot();
|
||||
|
||||
$container = $kernel->getContainer();
|
||||
$this->assertInstanceOf('Gaufrette\Filesystem', $container->get('knp_gaufrette.filesystem_map')->get('foo'));
|
||||
}
|
||||
}
|
||||
11
Tests/Functional/Resources/config/config.yml
Normal file
11
Tests/Functional/Resources/config/config.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
knp_gaufrette:
|
||||
adapters:
|
||||
foo:
|
||||
local:
|
||||
directory: %kernel.root_dir%
|
||||
create: true
|
||||
|
||||
filesystems:
|
||||
foo:
|
||||
adapter: foo
|
||||
alias: foo_filesystem
|
||||
2
Tests/Functional/Resources/config/config_dev.yml
Normal file
2
Tests/Functional/Resources/config/config_dev.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
imports:
|
||||
- { resource: config.yml }
|
||||
7
Tests/Functional/Resources/config/config_test.yml
Normal file
7
Tests/Functional/Resources/config/config_test.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
imports:
|
||||
- { resource: config.yml }
|
||||
|
||||
knp_gaufrette:
|
||||
adapters:
|
||||
foo:
|
||||
in_memory: ~
|
||||
26
Tests/Functional/TestKernel.php
Normal file
26
Tests/Functional/TestKernel.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Knp\Bundle\GaufretteBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
class TestKernel extends Kernel
|
||||
{
|
||||
public function getRootDir()
|
||||
{
|
||||
return __DIR__.'/Resources';
|
||||
}
|
||||
|
||||
public function registerBundles()
|
||||
{
|
||||
return array(
|
||||
new \Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(),
|
||||
);
|
||||
}
|
||||
|
||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||
{
|
||||
$loader->load(__DIR__.'/Resources/config/config_'.$this->getEnvironment().'.yml');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user