Skip to content

Instantly share code, notes, and snippets.

@ftassi
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ftassi/4d37e52e38713fb20646 to your computer and use it in GitHub Desktop.
Save ftassi/4d37e52e38713fb20646 to your computer and use it in GitHub Desktop.
PageObjectExampleImplementation
class BookingPage extends Page
{
public function bookAs($firstName, $lastName, $email)
{
$bookingForm = $this->find('css', 'form#booking-form');
$bookingForm->fillField('booking[firstName]', $firstName);
$bookingForm->fillField('booking[lastName]', $lastName);
$bookingForm->fillField('booking[email]', $email);
}
public function book()
{
$this->pressButton('booking-submit-button');
}
}
public function testTheUserShouldBeAbleToBook()
{
//...
$page = $mink->getSession()->getPage();
$bookingForm = $page->find('css', 'form#booking-form');
$bookingForm->fillField('booking[firstName]', $firstName);
$bookingForm->fillField('booking[lastName]', $lastName);
$bookingForm->fillField('booking[email]', $email);
$page->pressButton('booking-submit-button');
}
public function testTheUserShouldBeAbleToBook()
{
//...
$bookingPage = $pageFactory->getPage('booking');
$bookingPage
->bookAs($firstName, $lastName, $email)
->book();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment