diff --git a/features/tables.feature b/features/tables.feature index cd2797b..8895101 100644 --- a/features/tables.feature +++ b/features/tables.feature @@ -160,3 +160,12 @@ Feature: Inspecting HTML tables | Engineering | Panteleimon Kita | moderator | | Support | Victor Otto | moderator | | Support | Melissa Kevorkian | moderator | + # Check that the full structure of the table on the page. + And the "User roles" table should be: + | Group | Username | Role | + | Engineering | Najib Randall | administrator | + | Support | Victor Otto | administrator | + | Engineering | Melor Vescovi | moderator | + | Support | Victor Otto | moderator | + | Engineering | Panteleimon Kita | moderator | + | Support | Melissa Kevorkian | moderator | diff --git a/src/Context/TableContext.php b/src/Context/TableContext.php index c738d7d..55bf964 100644 --- a/src/Context/TableContext.php +++ b/src/Context/TableContext.php @@ -233,6 +233,24 @@ public function assertNoTableData(string $name, TableNode $data): void } } + /** + * Checks that the given table matches the given structure and data. + * + * @param string $name + * The human readable name for the table. + * @param \Behat\Gherkin\Node\TableNode $data + * The expected structure and data of the table. + * + * @Then the :name table should be: + */ + public function assertExactTableData(string $name, TableNode $data): void + { + $table = $this->getTable($name); + if ($table->getData() !== $data->getRows()) { + throw new \RuntimeException("The table $name doesn't match the expected data."); + } + } + /** * Checks that the given table contains the given non-consecutive columns, identified by headers. *