diff --git a/Mf2/Parser.php b/Mf2/Parser.php
index c7cc02d..3cb5b82 100644
--- a/Mf2/Parser.php
+++ b/Mf2/Parser.php
@@ -62,7 +62,7 @@ function parse($input, $url = null, $convertClassic = true) {
* @param &array $curlInfo (optional) the results of curl_getinfo will be placed in this variable for debugging
* @return array|null canonical microformats2 array structure on success, null on failure
*/
-function fetch($url, $convertClassic = true, &$curlInfo=null) {
+function fetch($url, $convertClassic = true, &$curlInfo = null) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@@ -127,7 +127,7 @@ function unicodeTrim($str) {
* @param string $prefix The prefix to look for
* @return string|array The prefixed name of the first microfomats class found or false
*/
-function mfNamesFromClass($class, $prefix='h-') {
+function mfNamesFromClass($class, $prefix = 'h-') {
$class = str_replace(array(' ', ' ', "\n"), ' ', $class);
$classes = explode(' ', $class);
$classes = preg_grep('#^(h|p|u|dt|e)-([a-z0-9]+-)?[a-z]+(-[a-z]+)*$#', $classes);
@@ -366,7 +366,7 @@ public function __construct($input, $url = null, $jsonMode = false) {
if (empty($input)) {
$input = $emptyDocDefault;
}
-
+
if (class_exists('Masterminds\\HTML5')) {
$doc = new \Masterminds\HTML5(array('disable_html_ns' => true));
$doc = $doc->loadHTML($input);
@@ -482,7 +482,7 @@ private function resolveChildUrls(DOMElement $el) {
* @param bool $implied
* @see https://wiki.zegnat.net/media/textparsing.html
**/
- public function textContent(DOMElement $element, $implied=false)
+ public function textContent(DOMElement $element, $implied = false)
{
return preg_replace(
'/(^[\t\n\f\r ]+| +(?=\n)|(?<=\n) +| +(?= )|[\t\n\f\r ]+$)/',
@@ -490,7 +490,7 @@ public function textContent(DOMElement $element, $implied=false)
$this->elementToString($element, $implied)
);
}
- private function elementToString(DOMElement $input, $implied=false)
+ private function elementToString(DOMElement $input, $implied = false)
{
$output = '';
foreach ($input->childNodes as $child) {
@@ -1179,7 +1179,7 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =
);
if(trim($e->getAttribute('id')) !== '') {
- $parsed['id'] = trim($e->getAttribute("id"));
+ $parsed['id'] = trim($e->getAttribute('id'));
}
if($this->lang) {
@@ -1385,7 +1385,7 @@ public function upgradeRelTagToCategory(DOMElement $el) {
*/
public function parse($convertClassic = true, DOMElement $context = null) {
$this->convertClassic = $convertClassic;
- $mfs = $this->parse_recursive($context);
+ $mfs = $this->parseRecursive($context);
// Parse rels
list($rels, $rel_urls, $alternates) = $this->parseRelsAndAlternates();
@@ -1411,7 +1411,7 @@ public function parse($convertClassic = true, DOMElement $context = null) {
* @param int $depth: recursion depth
* @return array
*/
- public function parse_recursive(DOMElement $context = null, $depth = 0) {
+ public function parseRecursive(DOMElement $context = null, $depth = 0) {
$mfs = array();
$mfElements = $this->getRootMF($context);
@@ -1422,7 +1422,7 @@ public function parse_recursive(DOMElement $context = null, $depth = 0) {
$this->backcompat($node);
}
- $recurse = $this->parse_recursive($node, $depth + 1);
+ $recurse = $this->parseRecursive($node, $depth + 1);
// set bool flag for nested mf
$has_nested_mf = (bool) $recurse;
@@ -1486,6 +1486,18 @@ public function parse_recursive(DOMElement $context = null, $depth = 0) {
return $mfs;
}
+ /**
+ * Parse microformats recursively (deprecated)
+ * @param DOMElement $context: node to start with
+ * @param int $depth: recursion depth
+ * @return array
+ * @deprecated Use parseRecursive() instead
+ */
+ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
+ public function parse_recursive(DOMElement $context = null, $depth = 0) {
+ return $this->parseRecursive($context, $depth);
+ }
+
/**
* Parse From ID
@@ -1502,7 +1514,7 @@ public function parse_recursive(DOMElement $context = null, $depth = 0) {
* @param bool $htmlSafe = false whether or not to HTML-encode angle brackets in non e-* properties
* @return array
*/
- public function parseFromId($id, $convertClassic=true) {
+ public function parseFromId($id, $convertClassic = true) {
$matches = $this->xpath->query("//*[@id='{$id}']");
if (empty($matches))
diff --git a/phpcs.xml b/phpcs.xml
index 8e94cdd..5851760 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,7 +1,49 @@
- PHP-MF2 Standards
+ PHP-MF2 Coding Standards
+
./Mf2/Parser.php
+ ./tests/
+
+
+
+
+
+
+
+
+
+
+ tests/Mf2/ParseDTTest.php
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tests/*
+
diff --git a/tests/Mf2/ClassicMicroformatsTest.php b/tests/Mf2/ClassicMicroformatsTest.php
index e1c2481..6240636 100644
--- a/tests/Mf2/ClassicMicroformatsTest.php
+++ b/tests/Mf2/ClassicMicroformatsTest.php
@@ -18,6 +18,7 @@
* Mainly based off BC tables on https://microformats.org/wiki/microformats2#v2_vocabularies
*/
class ClassicMicroformatsTest extends TestCase {
+ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
protected function set_up() {
date_default_timezone_set('Europe/London');
}
@@ -147,7 +148,7 @@ public function testParsesHProduct() {
/**
* @see https://github.com/indieweb/php-mf2/issues/81
*/
- public function test_vevent() {
+ public function testVevent() {
$input = <<< EOT
XYZ Project Review
@@ -896,7 +897,7 @@ public function testHEntryRelTag() {
}
public function testHEntryRelTagInContent() {
- $input = <<< END
+ $input = <<< END
Entry content should not include the generated data element for rel tag backcompat test
@@ -904,13 +905,13 @@ public function testHEntryRelTagInContent() {
END;
- $parser = new Parser($input);
- $output = $parser->parse();
- $item = $output['items'][0];
+ $parser = new Parser($input);
+ $output = $parser->parse();
+ $item = $output['items'][0];
- $this->assertEquals(['test'], $item['properties']['category']);
- $this->assertEquals('Entry content should not include the generated data element for rel tag backcompat test', $item['properties']['content'][0]['value']);
- $this->assertEquals('Entry content should not include the generated data element for rel tag backcompat test', $item['properties']['content'][0]['html']);
+ $this->assertEquals(['test'], $item['properties']['category']);
+ $this->assertEquals('Entry content should not include the generated data element for rel tag backcompat test', $item['properties']['content'][0]['value']);
+ $this->assertEquals('Entry content should not include the generated data element for rel tag backcompat test', $item['properties']['content'][0]['html']);
}
/**
diff --git a/tests/Mf2/CombinedMicroformatsTest.php b/tests/Mf2/CombinedMicroformatsTest.php
index b275cb6..ae0638b 100644
--- a/tests/Mf2/CombinedMicroformatsTest.php
+++ b/tests/Mf2/CombinedMicroformatsTest.php
@@ -18,6 +18,7 @@
class CombinedMicroformatsTest extends TestCase {
use AssertIsType;
+ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
protected function set_up() {
date_default_timezone_set('Europe/London');
}
@@ -294,7 +295,7 @@ public function testMicroformatsNestedUnderUPropertyClassnamesDeriveValueFromURL
"rels":[],
"rel-urls": []
}';
- $mf = Mf2\parse($input);
+ $mf = Mf2\parse($input);
$this->assertJsonStringEqualsJsonString(json_encode($mf), $expected);
$this->assertEquals($mf['items'][0]['properties']['comment'][0]['value'], 'https://example.com/post1234');
@@ -345,18 +346,18 @@ public function testNestedMf1() {
}
public function testNoUrlFromRelOnMf2() {
- $input = <<< END
+ $input = <<< END
END;
- $parser = new Parser($input);
- $output = $parser->parse();
+ $parser = new Parser($input);
+ $output = $parser->parse();
- $this->assertArrayHasKey('name', $output['items'][0]['properties']);
- $this->assertArrayHasKey('content', $output['items'][0]['properties']);
- $this->assertArrayNotHasKey('url', $output['items'][0]['properties']);
+ $this->assertArrayHasKey('name', $output['items'][0]['properties']);
+ $this->assertArrayHasKey('content', $output['items'][0]['properties']);
+ $this->assertArrayNotHasKey('url', $output['items'][0]['properties']);
}
/**
@@ -378,7 +379,7 @@ public function testNestedValuePProperty() {
$output = $parser->parse();
$this->assertArrayHasKey('value', $output['items'][0]['properties']['location'][0]);
- $this->assertEquals("Portland, Oregon • 44°F", $output['items'][0]['properties']['location'][0]['value']);
+ $this->assertEquals('Portland, Oregon • 44°F', $output['items'][0]['properties']['location'][0]['value']);
}
/**
diff --git a/tests/Mf2/MicroformatsTestSuiteTest.php b/tests/Mf2/MicroformatsTestSuiteTest.php
index 855c1fd..ef8668f 100644
--- a/tests/Mf2/MicroformatsTestSuiteTest.php
+++ b/tests/Mf2/MicroformatsTestSuiteTest.php
@@ -6,164 +6,164 @@
final class TestSuiteParser extends \Mf2\Parser
{
- /** Actually textContent from before the whitespace normalisation merge (e8da04f93d548d26287a8980eca4216639cbc61d) */
- public function textContent(\DOMElement $el, $dummy=false) {
- $excludeTags = array('noframe', 'noscript', 'script', 'style', 'frames', 'frameset');
-
- if (isset($el->tagName) and in_array(strtolower($el->tagName), $excludeTags)) {
- return '';
- }
-
- $this->_resolveChildUrls($el);
-
- $clonedEl = $el->cloneNode(true);
-
- foreach ($this->xpath->query('.//img', $clonedEl) as $imgEl) {
- if ($imgEl->hasAttribute('alt')) {
- $replacement = $imgEl->getAttribute('alt');
- } else if ($imgEl->hasAttribute('src')) {
- $replacement = ' ' . $imgEl->getAttribute('src') . ' ';
- } else {
- $replacement = ''; // Bye bye IMG element.
- }
- $newNode = $this->doc->createTextNode($replacement);
- $imgEl->parentNode->replaceChild($newNode, $imgEl);
- }
-
- foreach ($excludeTags as $tagName) {
- foreach ($this->xpath->query(".//{$tagName}", $clonedEl) as $elToRemove) {
- $elToRemove->parentNode->removeChild($elToRemove);
- }
- }
-
- return \Mf2\unicodeTrim($clonedEl->textContent);
- }
-
- // Hack. Old textContent requires "resolveChildUrls", but that method is private.
- private $__resolveChildUrls = null;
- private function _resolveChildUrls(\DOMElement $element) {
- if (null === $this->__resolveChildUrls) {
- $reflectUpon = new \ReflectionClass($this);
- $this->__resolveChildUrls = $reflectUpon->getMethod('resolveChildUrls');
- $this->__resolveChildUrls->setAccessible(true);
- }
- return $this->__resolveChildUrls->invoke($this, $element);
- }
+ /** Actually textContent from before the whitespace normalisation merge (e8da04f93d548d26287a8980eca4216639cbc61d) */
+ public function textContent(\DOMElement $el, $dummy = false) {
+ $excludeTags = array('noframe', 'noscript', 'script', 'style', 'frames', 'frameset');
+
+ if (isset($el->tagName) and in_array(strtolower($el->tagName), $excludeTags)) {
+ return '';
+ }
+
+ $this->_resolveChildUrls($el);
+
+ $clonedEl = $el->cloneNode(true);
+
+ foreach ($this->xpath->query('.//img', $clonedEl) as $imgEl) {
+ if ($imgEl->hasAttribute('alt')) {
+ $replacement = $imgEl->getAttribute('alt');
+ } else if ($imgEl->hasAttribute('src')) {
+ $replacement = ' ' . $imgEl->getAttribute('src') . ' ';
+ } else {
+ $replacement = ''; // Bye bye IMG element.
+ }
+ $newNode = $this->doc->createTextNode($replacement);
+ $imgEl->parentNode->replaceChild($newNode, $imgEl);
+ }
+
+ foreach ($excludeTags as $tagName) {
+ foreach ($this->xpath->query(".//{$tagName}", $clonedEl) as $elToRemove) {
+ $elToRemove->parentNode->removeChild($elToRemove);
+ }
+ }
+
+ return \Mf2\unicodeTrim($clonedEl->textContent);
+ }
+
+ // Hack. Old textContent requires "resolveChildUrls", but that method is private.
+ private $__resolveChildUrls = null;
+ private function _resolveChildUrls(\DOMElement $element) {
+ if (null === $this->__resolveChildUrls) {
+ $reflectUpon = new \ReflectionClass($this);
+ $this->__resolveChildUrls = $reflectUpon->getMethod('resolveChildUrls');
+ $this->__resolveChildUrls->setAccessible(true);
+ }
+ return $this->__resolveChildUrls->invoke($this, $element);
+ }
}
class MicroformatsTestSuiteTest extends TestCase
{
- /**
- * @dataProvider mf1TestsProvider
- * @group microformats/tests/mf1
- */
- public function testMf1FromTestSuite($input, $expectedOutput)
- {
- $parser = new TestSuiteParser($input, 'http://example.com/');
- $this->assertEquals(
- $this->makeComparible(json_decode($expectedOutput, true)),
- $this->makeComparible(json_decode(json_encode($parser->parse()), true))
- );
- }
-
- /**
- * @dataProvider mf2TestsProvider
- * @group microformats/tests/mf2
- */
- public function testMf2FromTestSuite($input, $expectedOutput, $test)
- {
- if ($test === 'h-event/time') {
- $this->markTestIncomplete('This test does not match because we implement a proposed spec: https://github.com/microformats/microformats2-parsing/issues/4#issuecomment-373457720.');
- }
-
- $parser = new TestSuiteParser($input, 'http://example.com/');
- $this->assertEquals(
- $this->makeComparible(json_decode($expectedOutput, true)),
- $this->makeComparible(json_decode(json_encode($parser->parse()), true))
- );
- }
-
- /**
- * @dataProvider mixedTestsProvider
- * @group microformats/tests/mixed
- */
- public function testMixedFromTestSuite($input, $expectedOutput)
- {
- $parser = new TestSuiteParser($input, 'http://example.com/');
- $this->assertEquals(
- $this->makeComparible(json_decode($expectedOutput, true)),
- $this->makeComparible(json_decode(json_encode($parser->parse()), true))
- );
- }
-
- /**
- * To make arrays coming from JSON more easily comparible by PHPUnit:
- * * We sort arrays by key, normalising them, because JSON objects are unordered.
- * * We json_encode strings, and cut the starting and ending ", so PHPUnit better
- * shows whitespace characters like tabs and newlines.
- **/
- public function makeComparible($array)
- {
- ksort($array);
- foreach ($array as $key => $value) {
- if (gettype($value) === 'array') {
- $array[$key] = $this->makeComparible($value);
- } else if (gettype($value) === 'string') {
- $array[$key] = substr(json_encode($value), 1, -1);
- }
- }
- return $array;
- }
-
- /**
- * Data provider lists all tests from a specific directory in mf2/tests.
- **/
- public function htmlAndJsonProvider($subFolder = '')
- {
- // Get the actual wanted subfolder.
- $subFolder = '/mf2/tests/tests' . $subFolder;
- // Ripped out of the test-suite.php code:
- $finder = new \RegexIterator(
- new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(
- dirname(__FILE__) . '/../../vendor/' . $subFolder,
- \RecursiveDirectoryIterator::SKIP_DOTS
- )),
- '/^.+\.html$/i',
- \RecursiveRegexIterator::GET_MATCH
- );
- // Build the array of separate tests:
- $tests = array();
- foreach ($finder as $key => $value) {
- $dir = realpath(pathinfo($key, PATHINFO_DIRNAME));
- $testname = substr($dir, strpos($dir, $subFolder) + strlen($subFolder) + 1) . '/' . pathinfo($key, PATHINFO_FILENAME);
- $test = pathinfo($key, PATHINFO_BASENAME);
- $result = pathinfo($key, PATHINFO_FILENAME) . '.json';
- if (is_file($dir . '/' . $result)) {
- $tests[$testname] = array(
- 'input' => file_get_contents($dir . '/' . $test),
- 'expectedOutput' => file_get_contents($dir . '/' . $result),
- 'name' => $testname
- );
- }
- }
- return $tests;
- }
-
- /**
- * Following three functions are the actual dataProviders used by the test methods.
- */
- public function mf1TestsProvider()
- {
- return $this->htmlAndJsonProvider('/microformats-v1');
- }
-
- public function mf2TestsProvider()
- {
- return $this->htmlAndJsonProvider('/microformats-v2');
- }
-
- public function mixedTestsProvider()
- {
- return $this->htmlAndJsonProvider('/microformats-mixed');
- }
+ /**
+ * @dataProvider mf1TestsProvider
+ * @group microformats/tests/mf1
+ */
+ public function testMf1FromTestSuite($input, $expectedOutput)
+ {
+ $parser = new TestSuiteParser($input, 'http://example.com/');
+ $this->assertEquals(
+ $this->makeComparible(json_decode($expectedOutput, true)),
+ $this->makeComparible(json_decode(json_encode($parser->parse()), true))
+ );
+ }
+
+ /**
+ * @dataProvider mf2TestsProvider
+ * @group microformats/tests/mf2
+ */
+ public function testMf2FromTestSuite($input, $expectedOutput, $test)
+ {
+ if ($test === 'h-event/time') {
+ $this->markTestIncomplete('This test does not match because we implement a proposed spec: https://github.com/microformats/microformats2-parsing/issues/4#issuecomment-373457720.');
+ }
+
+ $parser = new TestSuiteParser($input, 'http://example.com/');
+ $this->assertEquals(
+ $this->makeComparible(json_decode($expectedOutput, true)),
+ $this->makeComparible(json_decode(json_encode($parser->parse()), true))
+ );
+ }
+
+ /**
+ * @dataProvider mixedTestsProvider
+ * @group microformats/tests/mixed
+ */
+ public function testMixedFromTestSuite($input, $expectedOutput)
+ {
+ $parser = new TestSuiteParser($input, 'http://example.com/');
+ $this->assertEquals(
+ $this->makeComparible(json_decode($expectedOutput, true)),
+ $this->makeComparible(json_decode(json_encode($parser->parse()), true))
+ );
+ }
+
+ /**
+ * To make arrays coming from JSON more easily comparible by PHPUnit:
+ * * We sort arrays by key, normalising them, because JSON objects are unordered.
+ * * We json_encode strings, and cut the starting and ending ", so PHPUnit better
+ * shows whitespace characters like tabs and newlines.
+ **/
+ public function makeComparible($array)
+ {
+ ksort($array);
+ foreach ($array as $key => $value) {
+ if (gettype($value) === 'array') {
+ $array[$key] = $this->makeComparible($value);
+ } else if (gettype($value) === 'string') {
+ $array[$key] = substr(json_encode($value), 1, -1);
+ }
+ }
+ return $array;
+ }
+
+ /**
+ * Data provider lists all tests from a specific directory in mf2/tests.
+ **/
+ public function htmlAndJsonProvider($subFolder = '')
+ {
+ // Get the actual wanted subfolder.
+ $subFolder = '/mf2/tests/tests' . $subFolder;
+ // Ripped out of the test-suite.php code:
+ $finder = new \RegexIterator(
+ new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(
+ dirname(__FILE__) . '/../../vendor/' . $subFolder,
+ \RecursiveDirectoryIterator::SKIP_DOTS
+ )),
+ '/^.+\.html$/i',
+ \RecursiveRegexIterator::GET_MATCH
+ );
+ // Build the array of separate tests:
+ $tests = array();
+ foreach ($finder as $key => $value) {
+ $dir = realpath(pathinfo($key, PATHINFO_DIRNAME));
+ $testname = substr($dir, strpos($dir, $subFolder) + strlen($subFolder) + 1) . '/' . pathinfo($key, PATHINFO_FILENAME);
+ $test = pathinfo($key, PATHINFO_BASENAME);
+ $result = pathinfo($key, PATHINFO_FILENAME) . '.json';
+ if (is_file($dir . '/' . $result)) {
+ $tests[$testname] = array(
+ 'input' => file_get_contents($dir . '/' . $test),
+ 'expectedOutput' => file_get_contents($dir . '/' . $result),
+ 'name' => $testname
+ );
+ }
+ }
+ return $tests;
+ }
+
+ /**
+ * Following three functions are the actual dataProviders used by the test methods.
+ */
+ public function mf1TestsProvider()
+ {
+ return $this->htmlAndJsonProvider('/microformats-v1');
+ }
+
+ public function mf2TestsProvider()
+ {
+ return $this->htmlAndJsonProvider('/microformats-v2');
+ }
+
+ public function mixedTestsProvider()
+ {
+ return $this->htmlAndJsonProvider('/microformats-mixed');
+ }
}
diff --git a/tests/Mf2/MicroformatsWikiExamplesTest.php b/tests/Mf2/MicroformatsWikiExamplesTest.php
index f269485..d3d0777 100644
--- a/tests/Mf2/MicroformatsWikiExamplesTest.php
+++ b/tests/Mf2/MicroformatsWikiExamplesTest.php
@@ -20,6 +20,7 @@
* @author Barnaby Walters waterpigs.co.uk
*/
class MicroformatsWikiExamplesTest extends TestCase {
+ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
protected function set_up() {
date_default_timezone_set('Europe/London');
}
@@ -39,7 +40,7 @@ public function testHandlesEmptyStringsCorrectly() {
}
public function testHandlesNullCorrectly() {
- $input = Null;
+ $input = null;
$expected = '{
"rels": {},
"rel-urls": {},
diff --git a/tests/Mf2/ParseDTTest.php b/tests/Mf2/ParseDTTest.php
index 28027d6..29252de 100644
--- a/tests/Mf2/ParseDTTest.php
+++ b/tests/Mf2/ParseDTTest.php
@@ -10,6 +10,7 @@
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
class ParseDTTest extends TestCase {
+ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
protected function set_up() {
date_default_timezone_set('Europe/London');
}
@@ -48,7 +49,6 @@ public function testParseDTHandlesDataInnerHTML() {
$parser = new Parser($input);
$output = $parser->parse();
-
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50', $output['items'][0]['properties']['start'][0]);
}
@@ -93,36 +93,36 @@ public function testParseDTHandlesTimeDatetimeAttr() {
* @group parseDT
*/
public function testParseDTHandlesTimeDatetimeAttrWithZ() {
- $input = '';
- $parser = new Parser($input);
- $output = $parser->parse();
+ $input = '';
+ $parser = new Parser($input);
+ $output = $parser->parse();
- $this->assertArrayHasKey('start', $output['items'][0]['properties']);
- $this->assertEquals('2012-08-05T14:50:00Z', $output['items'][0]['properties']['start'][0]);
+ $this->assertArrayHasKey('start', $output['items'][0]['properties']);
+ $this->assertEquals('2012-08-05T14:50:00Z', $output['items'][0]['properties']['start'][0]);
}
/**
* @group parseDT
*/
public function testParseDTHandlesTimeDatetimeAttrWithTZOffset() {
- $input = '';
- $parser = new Parser($input);
- $output = $parser->parse();
+ $input = '';
+ $parser = new Parser($input);
+ $output = $parser->parse();
- $this->assertArrayHasKey('start', $output['items'][0]['properties']);
- $this->assertEquals('2012-08-05T14:50:00-0700', $output['items'][0]['properties']['start'][0]);
+ $this->assertArrayHasKey('start', $output['items'][0]['properties']);
+ $this->assertEquals('2012-08-05T14:50:00-0700', $output['items'][0]['properties']['start'][0]);
}
/**
* @group parseDT
*/
public function testParseDTHandlesTimeDatetimeAttrWithTZOffset2() {
- $input = '';
- $parser = new Parser($input);
- $output = $parser->parse();
+ $input = '';
+ $parser = new Parser($input);
+ $output = $parser->parse();
- $this->assertArrayHasKey('start', $output['items'][0]['properties']);
- $this->assertEquals('2012-08-05T14:50:00-07:00', $output['items'][0]['properties']['start'][0]);
+ $this->assertArrayHasKey('start', $output['items'][0]['properties']);
+ $this->assertEquals('2012-08-05T14:50:00-07:00', $output['items'][0]['properties']['start'][0]);
}
/**
@@ -133,7 +133,6 @@ public function testParseDTHandlesTimeInnerHTML() {
$parser = new Parser($input);
$output = $parser->parse();
-
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50', $output['items'][0]['properties']['start'][0]);
}
diff --git a/tests/Mf2/ParseHtmlIdTest.php b/tests/Mf2/ParseHtmlIdTest.php
index 235dd86..d00390c 100644
--- a/tests/Mf2/ParseHtmlIdTest.php
+++ b/tests/Mf2/ParseHtmlIdTest.php
@@ -13,6 +13,7 @@
*
*/
class ParseHtmlIdTest extends TestCase {
+ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
protected function set_up() {
date_default_timezone_set('Europe/London');
}
diff --git a/tests/Mf2/ParseImpliedTest.php b/tests/Mf2/ParseImpliedTest.php
index 46a50b0..a11e400 100644
--- a/tests/Mf2/ParseImpliedTest.php
+++ b/tests/Mf2/ParseImpliedTest.php
@@ -13,6 +13,7 @@
* @todo some of these can be made into single tests with dataProviders
*/
class ParseImpliedTest extends TestCase {
+ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
protected function set_up() {
date_default_timezone_set('Europe/London');
}
@@ -147,22 +148,22 @@ public function testParsesImpliedUUrlFromNestedAHref() {
}
public function testParsesImpliedUUrlWithExplicitName() {
- $input = 'Some Name';
- $parser = new Parser($input);
- $output = $parser->parse();
+ $input = 'Some Name';
+ $parser = new Parser($input);
+ $output = $parser->parse();
- $this->assertArrayHasKey('url', $output['items'][0]['properties']);
- $this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
+ $this->assertArrayHasKey('url', $output['items'][0]['properties']);
+ $this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
}
public function testParsesImpliedNameWithExplicitURL() {
- $input = 'Some Name';
- $parser = new Parser($input);
- $output = $parser->parse();
+ $input = 'Some Name';
+ $parser = new Parser($input);
+ $output = $parser->parse();
- $this->assertArrayHasKey('url', $output['items'][0]['properties']);
- $this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
- $this->assertEquals('Some Name', $output['items'][0]['properties']['name'][0]);
+ $this->assertArrayHasKey('url', $output['items'][0]['properties']);
+ $this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
+ $this->assertEquals('Some Name', $output['items'][0]['properties']['name'][0]);
}
public function testMultipleImpliedHCards() {
diff --git a/tests/Mf2/ParseLanguageTest.php b/tests/Mf2/ParseLanguageTest.php
index be96da9..1e7af0d 100644
--- a/tests/Mf2/ParseLanguageTest.php
+++ b/tests/Mf2/ParseLanguageTest.php
@@ -11,6 +11,7 @@
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
class ParseLanguageTest extends TestCase {
+ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
protected function set_up() {
date_default_timezone_set('Europe/London');
}
@@ -57,45 +58,45 @@ public function testHtmlAndHEntryLang()
$this->assertEquals('es', $result['items'][0]['lang']);
} # end method testHtmlAndHEntryLang()
- /**
- * Test HTML fragment with only h-entry lang
- */
- public function testFragmentHEntryLangOnly()
- {
- $input = '
This test is in English.
';
- $parser = new Parser($input);
- $parser->lang = true;
- $result = $parser->parse();
-
- $this->assertArrayHasKey('lang', $result['items'][0]);
- $this->assertEquals('en', $result['items'][0]['lang']);
- } # end method testFragmentHEntryLangOnly()
-
- /**
- * Test HTML fragment with no lang
- */
- public function testFragmentHEntryNoLang()
- {
- $input = '
This test is in English.
';
- $parser = new Parser($input);
- $parser->lang = true;
- $result = $parser->parse();
-
- $this->assertArrayNotHasKey('lang', $result['items'][0]);
- } # end method testFragmentHEntryNoLang()
-
- /**
- * Test HTML fragment with no lang, loaded with loadXML()
- */
- public function testFragmentHEntryNoLangXML()
- {
- $input = new \DOMDocument();
- $input->loadXML('
This test is in English.
');
- $parser = new Parser($input);
- $result = $parser->parse();
-
- $this->assertArrayNotHasKey('lang', $result['items'][0]);
- } # end method testFragmentHEntryNoLangXML()
+ /**
+ * Test HTML fragment with only h-entry lang
+ */
+ public function testFragmentHEntryLangOnly()
+ {
+ $input = '
This test is in English.
';
+ $parser = new Parser($input);
+ $parser->lang = true;
+ $result = $parser->parse();
+
+ $this->assertArrayHasKey('lang', $result['items'][0]);
+ $this->assertEquals('en', $result['items'][0]['lang']);
+ } # end method testFragmentHEntryLangOnly()
+
+ /**
+ * Test HTML fragment with no lang
+ */
+ public function testFragmentHEntryNoLang()
+ {
+ $input = '
This test is in English.
';
+ $parser = new Parser($input);
+ $parser->lang = true;
+ $result = $parser->parse();
+
+ $this->assertArrayNotHasKey('lang', $result['items'][0]);
+ } # end method testFragmentHEntryNoLang()
+
+ /**
+ * Test HTML fragment with no lang, loaded with loadXML()
+ */
+ public function testFragmentHEntryNoLangXML()
+ {
+ $input = new \DOMDocument();
+ $input->loadXML('
This test is in English.
');
+ $parser = new Parser($input);
+ $result = $parser->parse();
+
+ $this->assertArrayNotHasKey('lang', $result['items'][0]);
+ } # end method testFragmentHEntryNoLangXML()
/**
* Test with different , h-entry lang, and h-entry without lang,
diff --git a/tests/Mf2/ParsePTest.php b/tests/Mf2/ParsePTest.php
index 746f7c1..6129ff0 100644
--- a/tests/Mf2/ParsePTest.php
+++ b/tests/Mf2/ParsePTest.php
@@ -12,6 +12,7 @@
class ParsePTest extends TestCase {
+ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
protected function set_up() {
date_default_timezone_set('Europe/London');
}
@@ -36,7 +37,6 @@ public function testParsePHandlesImg() {
$parser = new Parser($input);
$output = $parser->parse();
-
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('Example User', $output['items'][0]['properties']['name'][0]);
}
@@ -61,7 +61,6 @@ public function testParsePHandlesData() {
$parser = new Parser($input);
$output = $parser->parse();
-
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('Example User', $output['items'][0]['properties']['name'][0]);
}
diff --git a/tests/Mf2/ParseUTest.php b/tests/Mf2/ParseUTest.php
index b116df6..97a57a5 100644
--- a/tests/Mf2/ParseUTest.php
+++ b/tests/Mf2/ParseUTest.php
@@ -10,6 +10,7 @@
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
class ParseUTest extends TestCase {
+ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
protected function set_up() {
date_default_timezone_set('Europe/London');
}
@@ -31,7 +32,7 @@ public function testParseUHandlesA() {
*/
public function testParseUHandlesEmptyHrefAttribute() {
$input = '