Skip to content

Commit 5529259

Browse files
committed
fix some risky tests
1 parent 6c12aa8 commit 5529259

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

Tests/Encoder/XmlEncoderTest.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\Serializer\Tests\Fixtures\ScalarDummy;
1818
use Symfony\Component\Serializer\Encoder\XmlEncoder;
1919
use Symfony\Component\Serializer\Serializer;
20-
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
2120
use Symfony\Component\Serializer\Normalizer\CustomNormalizer;
2221
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
2322

@@ -435,23 +434,12 @@ public function testDecodeInvalidXml()
435434
$this->encoder->decode('<?xml version="1.0"?><invalid><xml>', 'xml');
436435
}
437436

437+
/**
438+
* @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
439+
*/
438440
public function testPreventsComplexExternalEntities()
439441
{
440-
$oldCwd = getcwd();
441-
chdir(__DIR__);
442-
443-
try {
444-
$this->encoder->decode('<?xml version="1.0"?><!DOCTYPE scan[<!ENTITY test SYSTEM "php://filter/read=convert.base64-encode/resource=XmlEncoderTest.php">]><scan>&test;</scan>', 'xml');
445-
chdir($oldCwd);
446-
447-
$this->fail('No exception was thrown.');
448-
} catch (\Exception $e) {
449-
chdir($oldCwd);
450-
451-
if (!$e instanceof UnexpectedValueException) {
452-
$this->fail('Expected UnexpectedValueException');
453-
}
454-
}
442+
$this->encoder->decode('<?xml version="1.0"?><!DOCTYPE scan[<!ENTITY test SYSTEM "php://filter/read=convert.base64-encode/resource=XmlEncoderTest.php">]><scan>&test;</scan>', 'xml');
455443
}
456444

457445
public function testDecodeEmptyXml()

0 commit comments

Comments
 (0)