From b0faaac2a2d6bbd7e93947cf75d82110e72735b0 Mon Sep 17 00:00:00 2001 From: madmatt Date: Wed, 5 Feb 2014 12:22:15 +1300 Subject: [PATCH] =?UTF-8?q?Add=20a=20new=20step:=20I=20should=20see=20?= =?UTF-8?q?=E2=80=9Csome=20text=20value=E2=80=9D=20in=20the=20=E2=80=9CTab?= =?UTF-8?q?le=20Name=E2=80=9D=20table.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The table name is generally specified by the element within the itself. --- .../BehatExtension/Context/BasicContext.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index 9ce09bd..ea5fe2f 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -421,6 +421,24 @@ JS; } } + /** + * Finds a named
element. See {@link \Behat\Mink\Selector\NamedSelector} for ways to specify how to find + * the table. The easiest of these is adding a
element to the table in question. + * + * @Then /^I should see "([^"]*)" in the "([^"]*)" table$/ + */ + public function iShouldSeeInTheTable($value, $tableName) { + // Get table + $page = $this->getSession()->getPage(); + $table = $page->find('named', array('table', "$tableName")); + + if($table) { + assertContains($value, $table->getText(), "Couldn't find '$value' in the '$tableName' table"); + } else { + throw new \InvalidArgumentException("Couldn't find a table called '$tableName'"); + } + } + /** * Transforms relative time statements compatible with strtotime(). * Example: "time of 1 hour ago" might return "22:00:00" if its currently "23:00:00".