From 4d77dc65658b7b5851a6150310c6d237d0b4f0ec Mon Sep 17 00:00:00 2001 From: Mateusz Uzdowski Date: Tue, 1 Apr 2014 15:48:12 +1300 Subject: [PATCH] BUG Add a guard to prevent Behat runs from failing. --- code/TestSessionEnvironment.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/code/TestSessionEnvironment.php b/code/TestSessionEnvironment.php index 6edf78a..c5c0e0e 100644 --- a/code/TestSessionEnvironment.php +++ b/code/TestSessionEnvironment.php @@ -278,10 +278,12 @@ class TestSessionEnvironment extends Object { } } - file_put_contents( - $this->getFilePath(), - json_encode($state, JSON_PRETTY_PRINT) - ); + if (defined('JSON_PRETTY_PRINT')) { + $content = json_encode($state, JSON_PRETTY_PRINT); + } else { + $content = json_encode($state); + } + file_put_contents($this->getFilePath(), $content); $this->extend('onAfterApplyState'); } @@ -383,4 +385,4 @@ class TestSessionEnvironment extends Object { $path = Director::getAbsFile($this->getFilePath()); return (file_exists($path)) ? json_decode(file_get_contents($path)) : new stdClass; } -} \ No newline at end of file +}