assertAnySelectorTextNotContains example

public function testAssertAnySelectorTextSame()
    {
        $this->getCrawlerTester(new Crawler('<ul><li>Bar</li><li>Foo'))->assertAnySelectorTextSame('ul li', 'Foo');
        $this->expectException(AssertionFailedError::class);
        $this->expectExceptionMessage('matches selector "ul li" and has at least a node matching selector "ul li" with content "Foo".');
        $this->getCrawlerTester(new Crawler('<ul><li>Bar</li><li>Baz'))->assertAnySelectorTextSame('ul li', 'Foo');
    }

    public function testAssertAnySelectorTextNotContains()
    {
        $this->getCrawlerTester(new Crawler('<ul><li>Bar</li><li>Baz'))->assertAnySelectorTextNotContains('ul li', 'Foo');
        $this->expectException(AssertionFailedError::class);
        $this->expectExceptionMessage('matches selector "ul li" and the text of any node matching selector "ul li" does not contain "Foo".');
        $this->getCrawlerTester(new Crawler('<ul><li>Bar</li><li>Foo'))->assertAnySelectorTextNotContains('ul li', 'Foo');
    }

    public function testAssertPageTitleSame()
    {
        $this->getCrawlerTester(new Crawler('<html><head><title>Foo'))->assertPageTitleSame('Foo');
        $this->expectException(AssertionFailedError::class);
        $this->expectExceptionMessage('matches selector "title" and has a node matching selector "title" with content "Bar".');
        $this->getCrawlerTester(new Crawler('<html><head><title>Foo'))->assertPageTitleSame('Bar');
    }
Home | Imprint | This part of the site doesn't use cookies.