diff --git a/test/phpunit/TranslatorTest.php b/test/phpunit/TranslatorTest.php index 43ec5d8..eaac612 100644 --- a/test/phpunit/TranslatorTest.php +++ b/test/phpunit/TranslatorTest.php @@ -115,6 +115,40 @@ public function testFirstOfTypeNthOfTypeLastOfType() { self::assertEquals('table', $matches->item(1)->nodeValue); } + public function testLastOfType() { + $document = new DOMDocument("1.0", "UTF-8"); + $document->loadHTML(Helper::HTML_CHECKBOX); + + $xpath = new DOMXPath($document); + $selector = new Translator("form label:last-of-type input"); + + $matches = $xpath->query($selector); + self::assertEquals(1, $this->count($matches)); + /** @var \DOMElement $matchingInputElement */ + $matchingInputElement = $matches->item(0); + self::assertEquals( + "3", + $matchingInputElement->getAttribute("value") + ); + } + + public function testNthOfType() { + $document = new DOMDocument("1.0", "UTF-8"); + $document->loadHTML(Helper::HTML_CHECKBOX); + + $xpath = new DOMXPath($document); + $selector = new Translator("form label:nth-of-type(2) input"); + + $matches = $xpath->query($selector); + self::assertEquals(1, $this->count($matches)); + /** @var \DOMElement $matchingInputElement */ + $matchingInputElement = $matches->item(0); + self::assertEquals( + "2", + $matchingInputElement->getAttribute("value") + ); + } + public function testFirstNthLastChild() { $document = new DOMDocument("1.0", "UTF-8"); $document->loadHTML('
Track & field champions:
@@ -296,7 +330,7 @@ public function testCaseSensitivityHtmlMode() { 0, $xpath->query($attributeValueCaseSensitive)->length ); - + $tagNameCaseInsensitive = new Translator( "dIv" );