0

I'm very newbie with Mink, Behat, etc so I need help.

I've a table with some rows and I want to check if one row is deleted.

In my scenario I've something like this:

When I press "Delete"
Then I should be on "/example_url/"
    And I should see "Object list"
    And the response should not contain "Value1" "Value2" "Value3" "Value4"

How I do this? How I do "the response should not contain some values of one row"?

I don't know if this is possible with Mink or I need use Unitary Test.

Vitalii Zurian
  • 17,858
  • 4
  • 64
  • 81
Biruwon
  • 394
  • 1
  • 4
  • 18

1 Answers1

1

You can use tables in your steps:

And the result table should not contain:
  |Value |
  |Value1|
  |Value2|
  |Value3|
  |Value4|

Behat will pass it to your step method as a TableNode instance:

/**
 * @Given /the result table should not contain:/
 */
public function thePeopleExist(TableNode $table)
{
    $hash = $table->getHash();
    foreach ($hash as $row) {
        // ...
    }
}

Read more on writing features in the Gherkin language: http://docs.behat.org/guides/1.gherkin.html

Digression: Note that most of the time using Mink steps directly in your features is not the best idea since most of the time it's not the language of your business. Your scenario would be more readable and maintainable if you had written:

When I press "Delete"
Then I should be on the user page
 And I should see a list of users
 And the following users should be deleted:
   |Name   |
   |Biruwon|
   |Kuba   |
   |Anna   |

In your step implementation you can use the default Mink steps by returning Then instance:

/**
 * @Given /^I should see a list of users$/
 */
public function iShouldSeeListOfUsers()
{
    return new Then('I should see "User list"');
}
Jakub Zalas
  • 35,761
  • 9
  • 93
  • 125