You are here

public function CrawlerTest::testMissingAttrValueIsNull in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dom-crawler/Tests/CrawlerTest.php \Symfony\Component\DomCrawler\Tests\CrawlerTest::testMissingAttrValueIsNull()

File

vendor/symfony/dom-crawler/Tests/CrawlerTest.php, line 352

Class

CrawlerTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testMissingAttrValueIsNull() {
  $crawler = new Crawler();
  $crawler
    ->addContent('<html><div non-empty-attr="sample value" empty-attr=""></div></html>', 'text/html; charset=UTF-8');
  $div = $crawler
    ->filterXPath('//div');
  $this
    ->assertEquals('sample value', $div
    ->attr('non-empty-attr'), '->attr() reads non-empty attributes correctly');
  $this
    ->assertEquals('', $div
    ->attr('empty-attr'), '->attr() reads empty attributes correctly');
  $this
    ->assertNull($div
    ->attr('missing-attr'), '->attr() reads missing attributes correctly');
}