Skip to content

Commit

Permalink
[TableContext]: fix integer value for text assertion (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Beru authored Jan 20, 2023
1 parent 9ac872f commit 2eb5e5e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/Context/TableContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion tests/features/table.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
7 changes: 5 additions & 2 deletions tests/fixtures/www/table/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@
<tr>
<th class="foo bar">Lorem</th>
<th>Ipsum</th>
<th>Integer</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="2">Lorem ipsum dolor sit amet</td>
<td colspan="3">Lorem ipsum dolor sit amet</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
<td>42</td>
</tr>
<tr>
<td>Dolor</td>
<td>Sit</td>
<td>24</td>
</tr>
</tbody>
</table>
</table>

0 comments on commit 2eb5e5e

Please sign in to comment.