8000 [DependencyInjection] split a test · symfony/symfony@253a8ff · GitHub
[go: up one dir, main page]

Skip to content

Commit 253a8ff

Browse files
sebastianbergmannfabpot
authored andcommitted
[DependencyInjection] split a test
1 parent 1c3e6c2 commit 253a8ff

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

tests/Symfony/Tests/Component/DependencyInjection/Loader/IniFileLoaderTest.php

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,53 @@ class IniFileLoaderTest extends \PHPUnit_Framework_TestCase
1919
{
2020
static protected $fixturesPath;
2121

22+
protected $container;
23+
protected $loader;
24+
2225
static public function setUpBeforeClass()
2326
{
2427
self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
2528
}
2629

30+
protected function setUp()
31+
{
32+
$this->container = new ContainerBuilder();
33+
$this->loader = new IniFileLoader($this->container, new FileLocator(self::$fixturesPath.'/ini'));
34+
}
35+
2736
/**
2837
* @covers Symfony\Component\DependencyInjection\Loader\IniFileLoader::__construct
2938
* @covers Symfony\Component\DependencyInjection\Loader\IniFileLoader::load
3039
*/
31-
public function testLoader()
40+
public function testIniFileCanBeLoaded()
3241
{
33-
$container = new ContainerBuilder();
34-
$loader = new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/ini'));
35-
$loader->load('parameters.ini');
36-
$this->assertEquals(array('foo' => 'bar', 'bar' => '%foo%'), $container->getParameterBag()->all(), '->load() takes a single file name as its first argument');
42+
$this->loader->load('parameters.ini');
43+
$this->assertEquals(array('foo' => 'bar', 'bar' => '%foo%'), $this->container->getParameterBag()->all(), '->load() takes a single file name as its first argument');
44+
}
3745

46+
/**
47+
* @covers Symfony\Component\DependencyInjection\Loader\IniFileLoader::__construct
48+
* @covers Symfony\Component\DependencyInjection\Loader\IniFileLoader::load
49+
*/
50+
public function testExceptionIsRaisedWhenIniFileDoesNotExist()
51+
{
3852
try {
39-
$loader->load('foo.ini');
53+
$this->loader->load('foo.ini');
4054
$this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist');
4155
} catch (\Exception $e) {
4256
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file does not exist');
4357
$this->assertStringStartsWith('The file "foo.ini" does not exist (in: ', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file does not exist');
4458
}
59+
}
4560

61+
/**
62+
* @covers Symfony\Component\DependencyInjection\Loader\IniFileLoader::__construct
63+
* @covers Symfony\Component\DependencyInjection\Loader\IniFileLoader::load
64+
*/
65+
public function testExceptionIsRaisedWhenIniFileCannotBeParsed()
66+
{
4667
try {
47-
@$loader->load('nonvalid.ini');
68+
@$this->loader->load('nonvalid.ini');
4869
$this->fail('->load() throws an InvalidArgumentException if the loaded file is not parseable');
4970
} catch (\Exception $e) {
5071
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file is not parseable');

0 commit comments

Comments
 (0)
0