Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c254a4

Browse files
committed
Merge branch '2.4' into 2.5
* 2.4: typo fixed in AbstractProcessTest (getoutput() => getOutput()) Avoid question mark and asterisk in folder names to prevent windows filesystem issues. [Translation] [Config] Clear libxml errors after parsing XML file
2 parents 33b30a8 + 924d06a commit 1c254a4

File tree

7 files changed

+35
-7
lines changed

7 files changed

+35
-7
lines changed

src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ public function testLoadFile()
5858
}
5959

6060
$this->assertInstanceOf('DOMDocument', XmlUtils::loadFile($fixtures.'valid.xml', array($mock, 'validate')));
61+
$this->assertSame(array(), libxml_get_errors());
62+
}
63+
64+
public function testLoadFileWithInternalErrorsEnabled()
65+
{
66+
libxml_use_internal_errors(true);
67+
68+
$this->assertSame(array(), libxml_get_errors());
69+
$this->assertInstanceOf('DOMDocument', XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/invalid_schema.xml'));
70+
$this->assertSame(array(), libxml_get_errors());
6171
}
6272

6373
/**

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ public static function loadFile($file, $schemaOrCallable = null)
9595
}
9696
throw new \InvalidArgumentException(implode("\n", $messages), 0, $e);
9797
}
98-
99-
libxml_use_internal_errors($internalErrors);
10098
}
10199

100+
libxml_clear_errors();
101+
libxml_use_internal_errors($internalErrors);
102+
102103
return $dom;
103104
}
104105

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,11 @@ public function testIteratorKeys(Adapter\AdapterInterface $adapter)
586586
public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartFlag(Adapter\AdapterInterface $adapter)
587587
{
588588
$finder = $this->buildFinder($adapter);
589-
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.g?e*x[c]a(r)s')
589+
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.gex[c]a(r)s')
590590
->path('/^dir/');
591591

592-
$expected = array('r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir',
593-
'r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',);
592+
$expected = array('r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir',
593+
'r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',);
594594
$this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
595595
}
596596

src/Symfony/Component/Process/Tests/AbstractProcessTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ public function testSignal()
802802
usleep(500000);
803803
$process->signal(SIGUSR1);
804804

805-
while ($process->isRunning() && false === strpos($process->getoutput(), 'Caught SIGUSR1')) {
805+
while ($process->isRunning() && false === strpos($process->getOutput(), 'Caught SIGUSR1')) {
806806
usleep(10000);
807807
}
808808

src/Symfony/Component/Translation/Loader/XliffFileLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ private function parseFile($file)
116116

117117
$dom->normalizeDocument();
118118

119+
libxml_clear_errors();
119120
libxml_use_internal_errors($internalErrors);
120121

121122
return array(simplexml_import_dom($dom), strtoupper($dom->encoding));
@@ -124,7 +125,7 @@ private function parseFile($file)
124125
/**
125126
* Returns the XML errors of the internal XML parser
126127
*
127-
* @param bool $internalErrors
128+
* @param bool $internalErrors
128129
*
129130
* @return array An array of errors
130131
*/

src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ public function testLoad()
2424

2525
$this->assertEquals('en', $catalogue->getLocale());
2626
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
27+
$this->assertSame(array(), libxml_get_errors());
28+
}
29+
30+
public function testLoadWithInternalErrorsEnabled()
31+
{
32+
libxml_use_internal_errors(true);
33+
34+
$this->assertSame(array(), libxml_get_errors());
35+
36+
$loader = new XliffFileLoader();
37+
$resource = __DIR__.'/../fixtures/resources.xlf';
38+
$catalogue = $loader->load($resource, 'en', 'domain1');
39+
40+
$this->assertEquals('en', $catalogue->getLocale());
41+
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
42+
$this->assertSame(array(), libxml_get_errors());
2743
}
2844

2945
public function testLoadWithResname()

0 commit comments

Comments
 (0)