diff --git a/.travis.yml b/.travis.yml index 01fb5940..178389f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ php: - 5.6 - 7.0 - 7.1 + - 7.2 - hhvm - nightly diff --git a/composer.json b/composer.json index b6135efc..9ccfbc5f 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "require" : { "php" : ">=5.5.0", "querypath/QueryPath": ">=3.0.4", - "sebastian/diff": "~1.2", + "sebastian/diff": "^1.2 || ^2 || ^3", "marc1706/fast-image-size": "1.*", "masterminds/html5": "^2.2.0", "sabberworm/php-css-parser": "^8.0.0", @@ -25,7 +25,7 @@ }, "require-dev": { "php" : ">=5.5.0", - "phpunit/phpunit": "4.8.*", + "phpunit/phpunit": "4.8.* || ^6", "symfony/console": "^2.7.0" } } diff --git a/tests/AmpTest.php b/tests/AmpTest.php index d5c6eea3..3dfeb720 100644 --- a/tests/AmpTest.php +++ b/tests/AmpTest.php @@ -17,11 +17,12 @@ */ use Lullabot\AMP\AMP; +use PHPUnit\Framework\TestCase; /** * Class AmpTest */ -class AmpTest extends PHPUnit_Framework_TestCase +class AmpTest extends TestCase { /** @var AMP */ protected $amp = null; @@ -43,7 +44,7 @@ public function testFiles($test_filename, $fragment) { $options = $this->amp->getOptionsFromStandardOptionFile($test_filename); $output = $this->amp->consoleOutput($test_filename, $options, $fragment, true, true); - $expected_output = @file_get_contents("$test_filename.out"); + $expected_output = $this->getExpectedOutput($test_filename); if ($expected_output === false) { // An out file does not exist, skip this test $this->markTestSkipped("$test_filename.out file does not exist. Skipping test."); @@ -55,6 +56,19 @@ public function testFiles($test_filename, $fragment) $this->assertEquals($expected_output, $output); } + protected function getExpectedOutput($test_filename) + { + $version = explode('.', PHP_VERSION); + // Check if a specific version for this PHP exists. + if (file_exists("$test_filename.php{$version[0]}.out")) { + $filename = "$test_filename.php{$version[0]}.out"; + } + else { + $filename = "$test_filename.out"; + } + return @file_get_contents($filename); + } + public function filenameProvider() { $all_tests = []; diff --git a/tests/test-data/fragment-html/diff_test.html.php7.out b/tests/test-data/fragment-html/diff_test.html.php7.out new file mode 100644 index 00000000..9a0e12fc --- /dev/null +++ b/tests/test-data/fragment-html/diff_test.html.php7.out @@ -0,0 +1,18 @@ +--- Original ++++ New +@@ @@ +- ++ ++ ++ +