/** * @covers ::setDom * @covers ::getDom */ public function testSetDom() { $subject = new Subject(''); $dom = new \DOMDocument(); $subject->setDom($dom); $reflector = new \ReflectionClass($subject); $domProperty = $reflector->getProperty('dom'); $domProperty->setAccessible(true); $this->assertSame($dom, $domProperty->getValue($subject)); $this->assertSame($dom, $subject->getDom()); }
/** * @covers ::check */ public function testCheckEmptyAlt() { $html = '<html><body><img src="" alt=""></body></html>'; $dom = new \DOMDocument(); $dom->loadHTML($html); $subject = new Subject(''); $subject->setDom($dom); $resultCollection = $this->imageRule->check($subject); $this->assertSame(1, $resultCollection->count()); /** * @var Result $result */ $result = $resultCollection->current(); $this->assertSame('1 img tag is missing alt attribute', $result->getDescription()); }
/** * @covers ::check */ public function testCheckTooManyTitleTags() { $html = '<html><head><title>Foo</title><title>Bar</title></head></html>'; $dom = new \DOMDocument(); $dom->loadHTML($html); $subject = new Subject(''); $subject->setDom($dom); $resultCollection = $this->titleRule->check($subject); $this->assertSame(1, $resultCollection->count()); /** * @var Result $result */ $result = $resultCollection->current(); $this->assertSame('There are more than one title tag', $result->getDescription()); }