Skip to content

Commit

Permalink
Allow multiple versions of diff and PHPUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpott committed Feb 28, 2018
1 parent 05b7650 commit 0bfa9a7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -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",
Expand All @@ -25,7 +25,7 @@
},
"require-dev": {
"php" : ">=5.5.0",
"phpunit/phpunit": "4.8.*",
"phpunit/phpunit": "4.8.* || ^6",
"symfony/console": "^2.7.0"
}
}
18 changes: 16 additions & 2 deletions tests/AmpTest.php
Expand Up @@ -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;
Expand All @@ -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.");
Expand All @@ -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 = [];
Expand Down
18 changes: 18 additions & 0 deletions tests/test-data/fragment-html/diff_test.html.php7.out
@@ -0,0 +1,18 @@
--- Original
+++ New
@@ @@
-<audio controls autoplay>
+<amp-audio controls autoplay><div fallback><div>Your browser does not support the <strong>audio</strong> tag</div><p>Try using recent versions of Google Chrome or Firefox</p></div>
<source src="//example.dd:8088/sites/default/files/drums.mp3" type="audio/mpeg">
- <source src="http://example.dd:8088/sites/default/files/drums.ogg" type="audio/ogg">
+ <source type="audio/ogg">
<source src="https://example.dd:8088/sites/default/files/drums.wav" type="audio/wav">
<track kind="captions" src="//example.dd:8088/sites/default/files/drums.en.vtt" srclang="en" label="English">
<track kind="captions" src="https://example.dd:8088/sites/default/files/drums.hi.vtt" srclang="hi" label="Hindi">
- <div>Your browser does not support the <strong>audio</strong> tag</div>
- <p>Try using recent versions of Google Chrome or Firefox</p>
-</audio>
+
+
+</amp-audio>

0 comments on commit 0bfa9a7

Please sign in to comment.