Knp\Bundle\KnpBundlesBundle\Features\Context\FeatureContext::assertThereIsElementContainingTexts PHP Method

assertThereIsElementContainingTexts() public method

public assertThereIsElementContainingTexts ( $element, Behat\Gherkin\Node\TableNode $table )
$table Behat\Gherkin\Node\TableNode
    public function assertThereIsElementContainingTexts($element, TableNode $table)
    {
        $nodes = $this->getSession()->getPage()->findAll('css', $element);
        $texts = array();
        foreach ($table->getRows() as $row) {
            $texts[] = $row[0];
        }
        if (count($nodes) == 0) {
            throw new ElementNotFoundException($this->getSession(), 'element', 'css', $element);
        }
        foreach ($nodes as $node) {
            try {
                foreach ($texts as $text) {
                    assertContains($text, $node->getText());
                }
                return;
            } catch (AssertException $e) {
                // search in next node
            }
        }
        $message = sprintf('The texts "%s" was not found in any element matching css "%s"', implode('", "', $texts), $element);
        throw new ElementTextException($message, $this->getSession(), $node);
    }