From 93650fb9b5d95139a29acb9c94f1d3d649252ad5 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 3 Feb 2019 01:03:45 +0000 Subject: [PATCH] PHP 5.5 compat --- tests/CommonMarkTestStrict.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/CommonMarkTestStrict.php b/tests/CommonMarkTestStrict.php index 6275d39..6687081 100644 --- a/tests/CommonMarkTestStrict.php +++ b/tests/CommonMarkTestStrict.php @@ -17,8 +17,8 @@ use PHPUnit\Framework\TestCase; class CommonMarkTestStrict extends TestCase { const SPEC_URL = 'https://raw.githubusercontent.com/jgm/CommonMark/master/spec.txt'; - const SPEC_LOCAL_CACHE = __DIR__ .'/spec_cache.txt'; - const SPEC_CACHE_SECONDS = 5 * 60; + const SPEC_LOCAL_CACHE = 'spec_cache.txt'; + const SPEC_CACHE_SECONDS = 300; protected $parsedown; @@ -45,14 +45,16 @@ class CommonMarkTestStrict extends TestCase public static function getSpec() { + $specPath = __DIR__ .'/'.self::SPEC_LOCAL_CACHE; + if ( - \is_file(self::SPEC_LOCAL_CACHE) - && \time() - \filemtime(self::SPEC_LOCAL_CACHE) < self::SPEC_CACHE_SECONDS + \is_file($specPath) + && \time() - \filemtime($specPath) < self::SPEC_CACHE_SECONDS ) { - $spec = \file_get_contents(self::SPEC_LOCAL_CACHE); + $spec = \file_get_contents($specPath); } else { $spec = \file_get_contents(self::SPEC_URL); - \file_put_contents(self::SPEC_LOCAL_CACHE, $spec); + \file_put_contents($specPath, $spec); } return $spec;