Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit98e109c

Browse files
committed
Update unit tests to test glob imports
1 parent0e5d09d commit98e109c

File tree

6 files changed

+86
-1
lines changed

6 files changed

+86
-1
lines changed

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

Lines 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‎

Lines 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‎

Lines 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 =newFileLocator(__DIR__.'/Fixtures/Again');
8099

81100
$this->assertEquals(

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

Lines 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‎

Lines 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+
publicfunctiontestLoadGlobImports()
177+
{
178+
$container =newContainerBuilder();
179+
$resolver =newLoaderResolver(array(
180+
newIniFileLoader($container,newFileLocator(self::$fixturesPath.'/ini')),
181+
newYamlFileLoader($container,newFileLocator(self::$fixturesPath.'/yml')),
182+
$loader =newXmlFileLoader($container,newFileLocator(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
publicfunctiontestLoadAnonymousServices()
177213
{
178214
$container =newContainerBuilder();

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

Lines 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+
publicfunctiontestLoadGlobImports()
137+
{
138+
$container =newContainerBuilder();
139+
$resolver =newLoaderResolver(array(
140+
newIniFileLoader($container,newFileLocator(self::$fixturesPath.'/ini')),
141+
newXmlFileLoader($container,newFileLocator(self::$fixturesPath.'/xml')),
142+
newPhpFileLoader($container,newFileLocator(self::$fixturesPath.'/php')),
143+
$loader =newYamlFileLoader($container,newFileLocator(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' =>newReference('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
publicfunctiontestLoadServices()
137161
{
138162
$container =newContainerBuilder();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp