fromConstraints example


        self::assertThat(self::getCrawler()new LogicalNot(new DomCrawlerConstraint\CrawlerSelectorExists($selector))$message);
    }

    public static function assertSelectorCount(int $expectedCount, string $selector, string $message = ''): void
    {
        self::assertThat(self::getCrawler()new DomCrawlerConstraint\CrawlerSelectorCount($expectedCount$selector)$message);
    }

    public static function assertSelectorTextContains(string $selector, string $text, string $message = ''): void
    {
        self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
            new DomCrawlerConstraint\CrawlerSelectorExists($selector),
            new DomCrawlerConstraint\CrawlerSelectorTextContains($selector$text)
        )$message);
    }

    public static function assertAnySelectorTextContains(string $selector, string $text, string $message = ''): void
    {
        self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
            new DomCrawlerConstraint\CrawlerSelectorExists($selector),
            new DomCrawlerConstraint\CrawlerAnySelectorTextContains($selector$text)
        )$message);
    }


    public static function assertResponseFormatSame(?string $expectedFormat, string $message = ''): void
    {
        self::assertThatForResponse(new ResponseConstraint\ResponseFormatSame(self::getRequest()$expectedFormat)$message);
    }

    public static function assertResponseRedirects(string $expectedLocation = null, int $expectedCode = null, string $message = ''): void
    {
        $constraint = new ResponseConstraint\ResponseIsRedirected();
        if ($expectedLocation) {
            $constraint = LogicalAnd::fromConstraints($constraintnew ResponseConstraint\ResponseHeaderSame('Location', $expectedLocation));
        }
        if ($expectedCode) {
            $constraint = LogicalAnd::fromConstraints($constraintnew ResponseConstraint\ResponseStatusCodeSame($expectedCode));
        }

        self::assertThatForResponse($constraint$message);
    }

    public static function assertResponseHasHeader(string $headerName, string $message = ''): void
    {
        self::assertThatForResponse(new ResponseConstraint\ResponseHasHeader($headerName)$message);
    }
Home | Imprint | This part of the site doesn't use cookies.