Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 98e109c

Browse filesBrowse files
committed
Update unit tests to test glob imports
1 parent 0e5d09d commit 98e109c
Copy full SHA for 98e109c

File tree

6 files changed

+86
-1
lines changed
Filter options

6 files changed

+86
-1
lines changed

‎src/Symfony/Component/Config/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
3.3.0
5+
-----
6+
7+
* allow config files to be loaded using a glob pattern
8+
49
3.0.0
510
-----
611

‎src/Symfony/Component/Config/FileLocator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/FileLocator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function locate($name, $currentPath = null, $first = true)
6262
$paths = array_unique($paths);
6363
$filepaths = array();
6464

65-
$load = function ($file) use(&$filepaths) {
65+
$load = function ($file) use (&$filepaths) {
6666
if (@file_exists($file)) {
6767
$filepaths[] = $file;
6868
}

‎src/Symfony/Component/Config/Tests/FileLocatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Tests/FileLocatorTest.php
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@ public function testLocate()
7676
'->locate() returns an array of absolute filenames'
7777
);
7878

79+
$this->assertEquals(
80+
array(
81+
__DIR__.'/Fixtures/Util'.DIRECTORY_SEPARATOR.'document_type.xml',
82+
__DIR__.'/Fixtures/Util'.DIRECTORY_SEPARATOR.'invalid.xml',
83+
__DIR__.'/Fixtures/Util'.DIRECTORY_SEPARATOR.'invalid_schema.xml',
84+
__DIR__.'/Fixtures/Util'.DIRECTORY_SEPARATOR.'valid.xml',
85+
__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml',
86+
__DIR__.'/Fixtures/Again'.DIRECTORY_SEPARATOR.'foo.xml',
87+
),
88+
$loader->locate('*.xml', __DIR__.'/Fixtures/Util', false),
89+
'->locate() load glob pattern'
90+
);
91+
92+
$this->assertEquals(
93+
array(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.DIRECTORY_SEPARATOR.'foo.xml'),
94+
$loader->locate('*.xml', __DIR__.'/Fixtures', false),
95+
'->locate() load glob pattern'
96+
);
97+
7998
$loader = new FileLocator(__DIR__.'/Fixtures/Again');
8099

81100
$this->assertEquals(

‎src/Symfony/Component/DependencyInjection/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CHANGELOG
1414
* using the `PhpDumper` with an uncompiled `ContainerBuilder` is deprecated and
1515
will not be supported anymore in 4.0
1616
* deprecated the `DefinitionDecorator` class in favor of `ChildDefinition`
17+
* allow config files to be loaded using a glob pattern
1718

1819
3.2.0
1920
-----

‎src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,42 @@ public function testLoadImports()
173173
$loader->load('services4_bad_import.xml');
174174
}
175175

176+
public function testLoadGlobImports()
177+
{
178+
$container = new ContainerBuilder();
179+
$resolver = new LoaderResolver(array(
180+
new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/ini')),
181+
new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yml')),
182+
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')),
183+
));
184+
$loader->setResolver($resolver);
185+
$loader->load('services2*.xml');
186+
187+
$actual = $container->getParameterBag()->all();
188+
$expected = array(
189+
'a string',
190+
'foo' => 'bar',
191+
'values' => array(
192+
0,
193+
'integer' => 4,
194+
100 => null,
195+
'true',
196+
true,
197+
false,
198+
'on',
199+
'off',
200+
'float' => 1.3,
201+
1000.3,
202+
'a string',
203+
array('foo', 'bar'),
204+
),
205+
'mixedcase' => array('MixedCaseKey' => 'value'),
206+
'constant' => PHP_EOL,
207+
);
208+
209+
$this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files');
210+
}
211+
176212
public function testLoadAnonymousServices()
177213
{
178214
$container = new ContainerBuilder();

‎src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,30 @@ public function testLoadImports()
133133
$loader->load('services4_bad_import.yml');
134134
}
135135

136+
public function testLoadGlobImports()
137+
{
138+
$container = new ContainerBuilder();
139+
$resolver = new LoaderResolver(array(
140+
new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/ini')),
141+
new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')),
142+
new PhpFileLoader($container, new FileLocator(self::$fixturesPath.'/php')),
143+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
144+
));
145+
$loader->setResolver($resolver);
146+
$loader->load('services2*.yml');
147+
148+
$actual = $container->getParameterBag()->all();
149+
$expected = array(
150+
'foo' => 'bar',
151+
'values' => array(true, false, PHP_INT_MAX),
152+
'bar' => '%foo%',
153+
'escape' => '@escapeme',
154+
'foo_bar' => new Reference('foo_bar'),
155+
'mixedcase' => array('MixedCaseKey' => 'value'),
156+
);
157+
$this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files');
158+
}
159+
136160
public function testLoadServices()
137161
{
138162
$container = new ContainerBuilder();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.