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

Skip to content

Commit 924d06a

Browse files
committed
Merge branch '2.3' into 2.4
* 2.3: 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 Conflicts: src/Symfony/Component/Config/Util/XmlUtils.php
2 parents 8efff1b + e47e4fa commit 924d06a

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
@@ -575,11 +575,11 @@ public function testIteratorKeys(Adapter\AdapterInterface $adapter)
575575
public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartFlag(Adapter\AdapterInterface $adapter)
576576
{
577577
$finder = $this->buildFinder($adapter);
578-
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.g?e*x[c]a(r)s')
578+
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.gex[c]a(r)s')
579579
->path('/^dir/');
580580

581-
$expected = array('r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir',
582-
'r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',);
581+
$expected = array('r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir',
582+
'r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',);
583583
$this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
584584
}
585585

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ public function testSignal()
763763
usleep(500000);
764764
$process->signal(SIGUSR1);
765765

766-
while ($process->isRunning() && false === strpos($process->getoutput(), 'Caught SIGUSR1')) {
766+
while ($process->isRunning() && false === strpos($process->getOutput(), 'Caught SIGUSR1')) {
767767
usleep(10000);
768768
}
769769

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)