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
This commit is contained in:
Fabien Potencier 2014-09-23 07:25:11 +02:00
commit 1c254a4f09
7 changed files with 35 additions and 7 deletions

View File

@ -58,6 +58,16 @@ class XmlUtilsTest extends \PHPUnit_Framework_TestCase
}
$this->assertInstanceOf('DOMDocument', XmlUtils::loadFile($fixtures.'valid.xml', array($mock, 'validate')));
$this->assertSame(array(), libxml_get_errors());
}
public function testLoadFileWithInternalErrorsEnabled()
{
libxml_use_internal_errors(true);
$this->assertSame(array(), libxml_get_errors());
$this->assertInstanceOf('DOMDocument', XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/invalid_schema.xml'));
$this->assertSame(array(), libxml_get_errors());
}
/**

View File

@ -95,10 +95,11 @@ class XmlUtils
}
throw new \InvalidArgumentException(implode("\n", $messages), 0, $e);
}
libxml_use_internal_errors($internalErrors);
}
libxml_clear_errors();
libxml_use_internal_errors($internalErrors);
return $dom;
}

View File

@ -586,11 +586,11 @@ class FinderTest extends Iterator\RealIteratorTestCase
public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartFlag(Adapter\AdapterInterface $adapter)
{
$finder = $this->buildFinder($adapter);
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.g?e*x[c]a(r)s')
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.gex[c]a(r)s')
->path('/^dir/');
$expected = array('r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir',
'r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',);
$expected = array('r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir',
'r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',);
$this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
}

View File

@ -802,7 +802,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
usleep(500000);
$process->signal(SIGUSR1);
while ($process->isRunning() && false === strpos($process->getoutput(), 'Caught SIGUSR1')) {
while ($process->isRunning() && false === strpos($process->getOutput(), 'Caught SIGUSR1')) {
usleep(10000);
}

View File

@ -116,6 +116,7 @@ class XliffFileLoader implements LoaderInterface
$dom->normalizeDocument();
libxml_clear_errors();
libxml_use_internal_errors($internalErrors);
return array(simplexml_import_dom($dom), strtoupper($dom->encoding));
@ -124,7 +125,7 @@ class XliffFileLoader implements LoaderInterface
/**
* Returns the XML errors of the internal XML parser
*
* @param bool $internalErrors
* @param bool $internalErrors
*
* @return array An array of errors
*/

View File

@ -24,6 +24,22 @@ class XliffFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
$this->assertSame(array(), libxml_get_errors());
}
public function testLoadWithInternalErrorsEnabled()
{
libxml_use_internal_errors(true);
$this->assertSame(array(), libxml_get_errors());
$loader = new XliffFileLoader();
$resource = __DIR__.'/../fixtures/resources.xlf';
$catalogue = $loader->load($resource, 'en', 'domain1');
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
$this->assertSame(array(), libxml_get_errors());
}
public function testLoadWithResname()