diff --git a/composer.json b/composer.json index 1c3563a..a2e9279 100644 --- a/composer.json +++ b/composer.json @@ -18,11 +18,11 @@ } }, "require-dev": { - "phpunit/phpunit": "^5.7", "mf2/tests": "dev-master#e9e2b905821ba0a5b59dab1a8eaf40634ce9cd49", "squizlabs/php_codesniffer": "^3.6.2", "dealerdirect/phpcodesniffer-composer-installer": "^0.7", - "phpcompatibility/php-compatibility": "^9.3" + "phpcompatibility/php-compatibility": "^9.3", + "yoast/phpunit-polyfills": "^1.0" }, "autoload": { "files": ["Mf2/Parser.php"] diff --git a/tests/Mf2/ClassicMicroformatsTest.php b/tests/Mf2/ClassicMicroformatsTest.php index 0150e08..5b192c3 100644 --- a/tests/Mf2/ClassicMicroformatsTest.php +++ b/tests/Mf2/ClassicMicroformatsTest.php @@ -8,7 +8,7 @@ use Mf2\Parser; use Mf2; -use PHPUnit_Framework_TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; /** * Classic Microformats Test @@ -17,8 +17,8 @@ * * Mainly based off BC tables on http://microformats.org/wiki/microformats2#v2_vocabularies */ -class ClassicMicroformatsTest extends PHPUnit_Framework_TestCase { - public function setUp() { +class ClassicMicroformatsTest extends TestCase { + protected function set_up() { date_default_timezone_set('Europe/London'); } diff --git a/tests/Mf2/CombinedMicroformatsTest.php b/tests/Mf2/CombinedMicroformatsTest.php index b6501b0..c8eea21 100644 --- a/tests/Mf2/CombinedMicroformatsTest.php +++ b/tests/Mf2/CombinedMicroformatsTest.php @@ -4,7 +4,8 @@ use Mf2\Parser; use Mf2; -use PHPUnit_Framework_TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use Yoast\PHPUnitPolyfills\Polyfills\AssertIsType; /** * Combined Microformats Test @@ -14,9 +15,10 @@ * * @todo implement */ -class CombinedMicroformatsTest extends PHPUnit_Framework_TestCase { +class CombinedMicroformatsTest extends TestCase { + use AssertIsType; - public function setUp() { + protected function set_up() { date_default_timezone_set('Europe/London'); } @@ -430,7 +432,7 @@ public function testEmptyPropertiesObjectInJSONMode() { // Repeat in non-JSON-mode: expect the raw PHP to be an array. Check that its serialization is not what we need for mf2 JSON. $parser = new Parser($input, null, false); $output = $parser->parse(); - $this->assertInternalType('array', $output['items'][0]['properties']); + $this->assertIsArray($output['items'][0]['properties']); $this->assertSame('[]', json_encode($output['items'][0]['properties'])); } diff --git a/tests/Mf2/MicroformatsTestSuiteTest.php b/tests/Mf2/MicroformatsTestSuiteTest.php index 3f0392f..855c1fd 100644 --- a/tests/Mf2/MicroformatsTestSuiteTest.php +++ b/tests/Mf2/MicroformatsTestSuiteTest.php @@ -2,6 +2,8 @@ namespace Mf2\Parser\Test; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; + final class TestSuiteParser extends \Mf2\Parser { /** Actually textContent from before the whitespace normalisation merge (e8da04f93d548d26287a8980eca4216639cbc61d) */ @@ -49,7 +51,7 @@ private function _resolveChildUrls(\DOMElement $element) { } } -class MicroformatsTestSuiteTest extends \PHPUnit_Framework_TestCase +class MicroformatsTestSuiteTest extends TestCase { /** * @dataProvider mf1TestsProvider diff --git a/tests/Mf2/MicroformatsWikiExamplesTest.php b/tests/Mf2/MicroformatsWikiExamplesTest.php index b32c705..b53bb54 100644 --- a/tests/Mf2/MicroformatsWikiExamplesTest.php +++ b/tests/Mf2/MicroformatsWikiExamplesTest.php @@ -7,7 +7,7 @@ namespace Mf2\Parser\Test; use Mf2\Parser; -use PHPUnit_Framework_TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; /** * Microformats Wiki Examples @@ -19,9 +19,8 @@ * * @author Barnaby Walters waterpigs.co.uk */ -class MicroformatsWikiExamplesTest extends PHPUnit_Framework_TestCase { - - public function setUp() { +class MicroformatsWikiExamplesTest extends TestCase { + protected function set_up() { date_default_timezone_set('Europe/London'); } @@ -179,7 +178,7 @@ public function testMoreDetailedPerson() { "type": ["h-card"], "properties": { "photo": [ - { + { "value": "https://webfwd.org/content/about-experts/300.mitchellbaker/mentor_mbaker.jpg", "alt": "photo of Mitchell" } diff --git a/tests/Mf2/ParseDTTest.php b/tests/Mf2/ParseDTTest.php index fb917d6..ae85149 100644 --- a/tests/Mf2/ParseDTTest.php +++ b/tests/Mf2/ParseDTTest.php @@ -7,11 +7,10 @@ namespace Mf2\Parser\Test; use Mf2\Parser; -use PHPUnit_Framework_TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; -class ParseDTTest extends PHPUnit_Framework_TestCase { - - public function setUp() { +class ParseDTTest extends TestCase { + protected function set_up() { date_default_timezone_set('Europe/London'); } diff --git a/tests/Mf2/ParseHtmlIdTest.php b/tests/Mf2/ParseHtmlIdTest.php index cb3f5b1..235dd86 100644 --- a/tests/Mf2/ParseHtmlIdTest.php +++ b/tests/Mf2/ParseHtmlIdTest.php @@ -7,13 +7,13 @@ use Mf2; use Mf2\Parser; -use PHPUnit_Framework_TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; /** - * + * */ -class ParseHtmlIdTest extends PHPUnit_Framework_TestCase { - public function setUp() { +class ParseHtmlIdTest extends TestCase { + protected function set_up() { date_default_timezone_set('Europe/London'); } diff --git a/tests/Mf2/ParseImpliedTest.php b/tests/Mf2/ParseImpliedTest.php index cea18fd..d806c1a 100644 --- a/tests/Mf2/ParseImpliedTest.php +++ b/tests/Mf2/ParseImpliedTest.php @@ -7,17 +7,16 @@ use Mf2; use Mf2\Parser; -use PHPUnit_Framework_TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; /** * @todo some of these can be made into single tests with dataProviders */ -class ParseImpliedTest extends PHPUnit_Framework_TestCase { - public function setUp() { +class ParseImpliedTest extends TestCase { + protected function set_up() { date_default_timezone_set('Europe/London'); } - public function testParsesImpliedPNameFromNodeValue() { $input = 'The Name'; $parser = new Parser($input); diff --git a/tests/Mf2/ParseLanguageTest.php b/tests/Mf2/ParseLanguageTest.php index ad2560d..be96da9 100644 --- a/tests/Mf2/ParseLanguageTest.php +++ b/tests/Mf2/ParseLanguageTest.php @@ -8,11 +8,10 @@ use Mf2\Parser; use Mf2; -use PHPUnit_Framework_TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; -class ParseLanguageTest extends PHPUnit_Framework_TestCase { - - public function setUp() { +class ParseLanguageTest extends TestCase { + protected function set_up() { date_default_timezone_set('Europe/London'); } diff --git a/tests/Mf2/ParsePTest.php b/tests/Mf2/ParsePTest.php index aba138e..ca06d5f 100644 --- a/tests/Mf2/ParsePTest.php +++ b/tests/Mf2/ParsePTest.php @@ -8,12 +8,11 @@ use Mf2; use Mf2\Parser; -use PHPUnit_Framework_TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; -class ParsePTest extends PHPUnit_Framework_TestCase { - - public function setUp() { +class ParsePTest extends TestCase { + protected function set_up() { date_default_timezone_set('Europe/London'); } diff --git a/tests/Mf2/ParseUTest.php b/tests/Mf2/ParseUTest.php index fa94aef..a49ab5a 100644 --- a/tests/Mf2/ParseUTest.php +++ b/tests/Mf2/ParseUTest.php @@ -7,10 +7,10 @@ use Mf2; use Mf2\Parser; -use PHPUnit_Framework_TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; -class ParseUTest extends PHPUnit_Framework_TestCase { - public function setUp() { +class ParseUTest extends TestCase { + protected function set_up() { date_default_timezone_set('Europe/London'); } diff --git a/tests/Mf2/ParseValueClassTitleTest.php b/tests/Mf2/ParseValueClassTitleTest.php index cea40b6..5947c09 100644 --- a/tests/Mf2/ParseValueClassTitleTest.php +++ b/tests/Mf2/ParseValueClassTitleTest.php @@ -8,11 +8,10 @@ use Mf2; use Mf2\Parser; -use PHPUnit_Framework_TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; -class ParseValueClassTitleTest extends PHPUnit_Framework_TestCase { - - public function setUp() { +class ParseValueClassTitleTest extends TestCase { + protected function set_up() { date_default_timezone_set('Europe/London'); } diff --git a/tests/Mf2/ParserTest.php b/tests/Mf2/ParserTest.php index 3338026..a364557 100644 --- a/tests/Mf2/ParserTest.php +++ b/tests/Mf2/ParserTest.php @@ -4,7 +4,9 @@ use Mf2\Parser; use Mf2; -use PHPUnit_Framework_TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use Yoast\PHPUnitPolyfills\Polyfills\AssertIsType; +use Yoast\PHPUnitPolyfills\Polyfills\AssertStringContains; /** * Parser Test @@ -14,9 +16,11 @@ * * Stuff for parsing E goes in here until there is enough of it to go elsewhere (like, never?) */ -class ParserTest extends PHPUnit_Framework_TestCase { +class ParserTest extends TestCase { + use AssertIsType; + use AssertStringContains; - public function setUp() { + protected function set_up() { date_default_timezone_set('Europe/London'); } @@ -265,7 +269,7 @@ public function testFetchMicroformats() { $mf = Mf2\fetch('http://waterpigs.co.uk/photo.jpg', null, $curlInfo); $this->assertNull($mf); - $this->assertContains('jpeg', $curlInfo['content_type']); + $this->assertStringContainsString('jpeg', $curlInfo['content_type']); } /** @@ -393,8 +397,11 @@ public function testScriptTagContentsRemovedFromTextValue() { $output = $parser->parse(); $this->assertContains('h-entry', $output['items'][0]['type']); - $this->assertContains('Hello World', $output['items'][0]['properties']['content'][0]); - $this->assertNotContains('alert', $output['items'][0]['properties']['content'][0]); + $this->assertStringContainsString( + 'Hello World', + $output['items'][0]['properties']['content'][0] + ); + $this->assertStringNotContainsString('alert', $output['items'][0]['properties']['content'][0]); } public function testScriptElementContentsRemovedFromAllPlaintextValues() { @@ -408,8 +415,8 @@ public function testScriptElementContentsRemovedFromAllPlaintextValues() { $parser = new Parser($input); $output = $parser->parse(); - $this->assertNotContains('not contained', $output['items'][0]['properties']['published'][0]); - $this->assertNotContains('not contained', $output['items'][0]['properties']['url'][0]); + $this->assertStringNotContainsString('not contained', $output['items'][0]['properties']['published'][0]); + $this->assertStringNotContainsString('not contained', $output['items'][0]['properties']['url'][0]); } public function testScriptTagContentsNotRemovedFromHTMLValue() { @@ -431,13 +438,13 @@ public function testScriptTagContentsNotRemovedFromHTMLValue() { $output = $parser->parse(); $this->assertContains('h-entry', $output['items'][0]['type']); - $this->assertContains('Hello World', $output['items'][0]['properties']['content'][0]['value']); - $this->assertContains('Hello World', $output['items'][0]['properties']['content'][0]['html']); + $this->assertStringContainsString('Hello World', $output['items'][0]['properties']['content'][0]['value']); + $this->assertStringContainsString('Hello World', $output['items'][0]['properties']['content'][0]['html']); # The script and style tags should be removed from plaintext results but left in HTML results. - $this->assertContains('alert', $output['items'][0]['properties']['content'][0]['html']); - $this->assertNotContains('alert', $output['items'][0]['properties']['content'][0]['value']); - $this->assertContains('visibility', $output['items'][0]['properties']['content'][0]['html']); - $this->assertNotContains('visibility', $output['items'][0]['properties']['content'][0]['value']); + $this->assertStringContainsString('alert', $output['items'][0]['properties']['content'][0]['html']); + $this->assertStringNotContainsString('alert', $output['items'][0]['properties']['content'][0]['value']); + $this->assertStringContainsString('visibility', $output['items'][0]['properties']['content'][0]['html']); + $this->assertStringNotContainsString('visibility', $output['items'][0]['properties']['content'][0]['value']); } public function testWhitespaceBetweenElements() { @@ -842,8 +849,8 @@ public function testNoImpliedURLForEmptyProperties() { EOD; $output = Mf2\parse($input); - $this->assertInternalType('array', $output['items'][0]['properties']['comment'][0]['properties']); - $this->assertInternalType('array', $output['items'][0]['properties']['comment'][0]['children'][0]['properties']); + $this->assertIsArray($output['items'][0]['properties']['comment'][0]['properties']); + $this->assertIsArray($output['items'][0]['properties']['comment'][0]['children'][0]['properties']); $this->assertEmpty($output['items'][0]['properties']['comment'][0]['properties']); $this->assertEmpty($output['items'][0]['properties']['comment'][0]['children'][0]['properties']); } diff --git a/tests/Mf2/PlainTextTest.php b/tests/Mf2/PlainTextTest.php index df9722f..621276e 100644 --- a/tests/Mf2/PlainTextTest.php +++ b/tests/Mf2/PlainTextTest.php @@ -1,8 +1,9 @@ '; $parser = new Parser($input); diff --git a/tests/Mf2/URLTest.php b/tests/Mf2/URLTest.php index e7d37d7..c670ba1 100644 --- a/tests/Mf2/URLTest.php +++ b/tests/Mf2/URLTest.php @@ -7,11 +7,10 @@ namespace Mf2\Parser\Test; use Mf2; -use PHPUnit_Framework_TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; -class UrlTest extends PHPUnit_Framework_TestCase { - - public function setUp() { +class UrlTest extends TestCase { + protected function set_up() { date_default_timezone_set('Europe/London'); }