Sanpi\Behatch\Context\TableContext::theDataOfTheRowShouldMatch PHP Метод

theDataOfTheRowShouldMatch() публичный Метод

Checks that the data of the specified row matches the given schema
public theDataOfTheRowShouldMatch ( $index, $table, Behat\Gherkin\Node\TableNode $text )
$text Behat\Gherkin\Node\TableNode
    public function theDataOfTheRowShouldMatch($index, $table, TableNode $text)
    {
        $rowsSelector = "{$table} tbody tr";
        $rows = $this->getSession()->getPage()->findAll('css', $rowsSelector);
        if (!isset($rows[$index - 1])) {
            throw new \Exception("The row {$index} was not found in the '{$table}' table");
        }
        $cells = (array) $rows[$index - 1]->findAll('css', 'td');
        $cells = array_merge((array) $rows[$index - 1]->findAll('css', 'th'), $cells);
        $hash = current($text->getHash());
        foreach (array_keys($hash) as $columnName) {
            // Extract index from column. ex "col2" -> 2
            preg_match('/^col(?P<index>\\d+)$/', $columnName, $matches);
            $index = (int) $matches['index'] - 1;
            $this->assertEquals($hash[$columnName], $cells[$index]->getText());
        }
    }