From 2eb5e5e4a73c80ef6542f8bf710a24601934bcf8 Mon Sep 17 00:00:00 2001 From: Hubert Lenoir Date: Fri, 20 Jan 2023 10:39:19 +0100 Subject: [PATCH] [TableContext]: fix integer value for text assertion (#15) --- src/Context/TableContext.php | 12 ++++++------ tests/features/table.feature | 4 +++- tests/fixtures/www/table/index.html | 7 +++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Context/TableContext.php b/src/Context/TableContext.php index 4c4c3bba..619c11c3 100644 --- a/src/Context/TableContext.php +++ b/src/Context/TableContext.php @@ -11,7 +11,7 @@ class TableContext extends BaseContext * * @Then the columns schema of the :table table should match: */ - public function theColumnsSchemaShouldMatch($table, TableNode $text): void + public function theColumnsSchemaShouldMatch(string $table, TableNode $text): void { $columnsSelector = "$table thead tr th"; $columns = $this->getSession()->getPage()->findAll('css', $columnsSelector); @@ -28,7 +28,7 @@ public function theColumnsSchemaShouldMatch($table, TableNode $text): void * * @Then (I )should see :count column(s) in the :table table */ - public function iShouldSeeColumnsInTheTable($count, $table): void + public function iShouldSeeColumnsInTheTable(int $count, string $table): void { $columnsSelector = "$table thead tr th"; $columns = $this->getSession()->getPage()->findAll('css', $columnsSelector); @@ -41,7 +41,7 @@ public function iShouldSeeColumnsInTheTable($count, $table): void * * @Then (I )should see :count rows in the :index :table table */ - public function iShouldSeeRowsInTheNthTable($count, $index, $table): void + public function iShouldSeeRowsInTheNthTable(int $count, int $index, string $table): void { $actual = $this->countElements('tbody tr', $index, $table); $this->assertEquals($count, $actual); @@ -52,7 +52,7 @@ public function iShouldSeeRowsInTheNthTable($count, $index, $table): void * * @Then (I )should see :count row(s) in the :table table */ - public function iShouldSeeRowsInTheTable($count, $table): void + public function iShouldSeeRowsInTheTable(int $count, string $table): void { $this->iShouldSeeRowsInTheNthTable($count, 1, $table); } @@ -62,7 +62,7 @@ public function iShouldSeeRowsInTheTable($count, $table): void * * @Then the data in the :index row of the :table table should match: */ - public function theDataOfTheRowShouldMatch($index, $table, TableNode $text): void + public function theDataOfTheRowShouldMatch(int $index, string $table, TableNode $text): void { $rowsSelector = "$table tbody tr"; $rows = $this->getSession()->getPage()->findAll('css', $rowsSelector); @@ -90,7 +90,7 @@ public function theDataOfTheRowShouldMatch($index, $table, TableNode $text): voi * * @Then the :colIndex column of the :rowIndex row in the :table table should contain :text */ - public function theStColumnOfTheStRowInTheTableShouldContain($colIndex, $rowIndex, $table, $text): void + public function theStColumnOfTheStRowInTheTableShouldContain(int $colIndex, int $rowIndex, string $table, string $text): void { $rowSelector = "$table tbody tr"; $rows = $this->getSession()->getPage()->findAll('css', $rowSelector); diff --git a/tests/features/table.feature b/tests/features/table.feature index 463fb957..6584624e 100644 --- a/tests/features/table.feature +++ b/tests/features/table.feature @@ -7,12 +7,13 @@ Feature: Browser Feature Scenario: Testing columns Given I am on "/table/index.html" - Then I should see 2 columns in the "table" table + Then I should see 3 columns in the "table" table And the columns schema of the "table" table should match: | columns | | Lorem | | Ipsum | + | Integer | Scenario: Testing rows Given I am on "/table/index.html" @@ -46,3 +47,4 @@ Feature: Browser Feature Given I am on "/table/index.html" Then the 1st column of the 1st row in the "table" table should contain "Lorem" And the 2nd column of the 1st row in the "table" table should contain "Ipsum" + And the 3rd column of the 1st row in the "table" table should contain "42" diff --git a/tests/fixtures/www/table/index.html b/tests/fixtures/www/table/index.html index fb164519..76480431 100644 --- a/tests/fixtures/www/table/index.html +++ b/tests/fixtures/www/table/index.html @@ -5,21 +5,24 @@ Lorem Ipsum + Integer - Lorem ipsum dolor sit amet + Lorem ipsum dolor sit amet Lorem Ipsum + 42 Dolor Sit + 24 - \ No newline at end of file +