Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
}
},
"require-dev": {
"phpunit/phpunit": "^5.7",
Copy link
Contributor Author

@Lewiscowles1986 Lewiscowles1986 Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets removed to add yoast/phpunit-polyfills dependency.

"mf2/tests": "dev-master#e9e2b905821ba0a5b59dab1a8eaf40634ce9cd49",
"squizlabs/php_codesniffer": "^3.6.2",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"phpcompatibility/php-compatibility": "^9.3"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation bothered me.

"phpcompatibility/php-compatibility": "^9.3",
"yoast/phpunit-polyfills": "^1.0"
},
"autoload": {
"files": ["Mf2/Parser.php"]
Expand Down
6 changes: 3 additions & 3 deletions tests/Mf2/ClassicMicroformatsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use Mf2\Parser;
use Mf2;
use PHPUnit_Framework_TestCase;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

/**
* Classic Microformats Test
Expand All @@ -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');
}

Expand Down
10 changes: 6 additions & 4 deletions tests/Mf2/CombinedMicroformatsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
}

Expand Down Expand Up @@ -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']));
}

Expand Down
4 changes: 3 additions & 1 deletion tests/Mf2/MicroformatsTestSuiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down Expand Up @@ -49,7 +51,7 @@ private function _resolveChildUrls(\DOMElement $element) {
}
}

class MicroformatsTestSuiteTest extends \PHPUnit_Framework_TestCase
class MicroformatsTestSuiteTest extends TestCase
{
/**
* @dataProvider mf1TestsProvider
Expand Down
9 changes: 4 additions & 5 deletions tests/Mf2/MicroformatsWikiExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Mf2\Parser\Test;

use Mf2\Parser;
use PHPUnit_Framework_TestCase;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

/**
* Microformats Wiki Examples
Expand All @@ -19,9 +19,8 @@
*
* @author Barnaby Walters waterpigs.co.uk <[email protected]>
*/
class MicroformatsWikiExamplesTest extends PHPUnit_Framework_TestCase {

public function setUp() {
class MicroformatsWikiExamplesTest extends TestCase {
protected function set_up() {
date_default_timezone_set('Europe/London');
}

Expand Down Expand Up @@ -179,7 +178,7 @@ public function testMoreDetailedPerson() {
"type": ["h-card"],
"properties": {
"photo": [
{
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one-liner may be a mistake... Lets see what CI says.

"value": "https://webfwd.org/content/about-experts/300.mitchellbaker/mentor_mbaker.jpg",
"alt": "photo of Mitchell"
}
Expand Down
7 changes: 3 additions & 4 deletions tests/Mf2/ParseDTTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Mf2/ParseHtmlIdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
7 changes: 3 additions & 4 deletions tests/Mf2/ParseImpliedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<span class="h-card">The Name</span>';
$parser = new Parser($input);
Expand Down
7 changes: 3 additions & 4 deletions tests/Mf2/ParseLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
7 changes: 3 additions & 4 deletions tests/Mf2/ParsePTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Mf2/ParseUTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
7 changes: 3 additions & 4 deletions tests/Mf2/ParseValueClassTitleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
39 changes: 23 additions & 16 deletions tests/Mf2/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
}

Expand Down Expand Up @@ -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']);
}

/**
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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('<b>Hello World</b>', $output['items'][0]['properties']['content'][0]['html']);
$this->assertStringContainsString('Hello World', $output['items'][0]['properties']['content'][0]['value']);
$this->assertStringContainsString('<b>Hello World</b>', $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() {
Expand Down Expand Up @@ -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']);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Mf2/PlainTextTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Mf2\Parser\Test;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

class PlainTextTest extends \PHPUnit_Framework_TestCase {
class PlainTextTest extends TestCase {
/**
* @dataProvider aaronpkExpectations
*/
Expand Down
8 changes: 2 additions & 6 deletions tests/Mf2/RelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@

use Mf2;
use Mf2\Parser;
use PHPUnit_Framework_TestCase;

class RelTest extends PHPUnit_Framework_TestCase {
public function setUp() {
date_default_timezone_set('Europe/London');
}
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

class RelTest extends TestCase {
public function testRelValueOnLinkTag() {
$input = '<link rel="webmention" href="http://example.com/webmention">';
$parser = new Parser($input);
Expand Down
7 changes: 3 additions & 4 deletions tests/Mf2/URLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down