diff options
author | Andres Rey <[email protected]> | 2017-03-13 13:26:25 +0000 |
---|---|---|
committer | Andres Rey <[email protected]> | 2017-03-13 13:26:25 +0000 |
commit | 361a1f73048a3f68af539344b0c294c9633f5820 (patch) | |
tree | eafcbbc14d1b41ce02d339bdd65456f345b76c1b /test | |
parent | 9b7351019b7481ca822d5f12fd8ebab9aa4f307c (diff) |
Failsafe for missing config files
Diffstat (limited to 'test')
-rw-r--r-- | test/HTMLParserTest.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/test/HTMLParserTest.php b/test/HTMLParserTest.php index 9d7586e..d3e785a 100644 --- a/test/HTMLParserTest.php +++ b/test/HTMLParserTest.php @@ -40,9 +40,13 @@ class HTMLParserTest extends \PHPUnit_Framework_TestCase $source = file_get_contents($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'source.html'); $expectedHTML = file_get_contents($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'expected.html'); $expectedMetadata = file_get_contents($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'expected-metadata.json'); - $config = file_get_contents($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'config.json'); - if ($config) { - $config = json_decode($config, true); + + $config = null; + if (file_exists($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'config.json')) { + $config = file_get_contents($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'config.json'); + if ($config) { + $config = json_decode($config, true); + } } $pages[$testPage] = [$source, $expectedHTML, $expectedMetadata, $config]; |