Skip to content

Instantly share code, notes, and snippets.

@laracasts
Last active August 29, 2015 14:17
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 laracasts/438807e138f5503eacf7 to your computer and use it in GitHub Desktop.
Save laracasts/438807e138f5503eacf7 to your computer and use it in GitHub Desktop.
Working on integration testing helper for PHPUnit.
<?php
class ExampleTest extends IntegrationTest
{
/** test */
public function it_verifies_that_pages_load_properly()
{
$this->visit('/');
}
/** test */
public function it_follows_links()
{
$this->visit('/page-1')
->click('Follow Me')
->andSee('You are on Page 2')
->onPage('/page-2');
}
/** @test */
public function it_submits_forms()
{
$this->visit('page-with-form')
->submitForm('Submit', ['title' => 'Foo Title'])
->andSee('You entered Foo Title')
->onPage('/page-with-form-results');
// Another way to write it.
$this->visit('page-with-form')
->type('Foo Title', '#title')
->press('Submit')
->see('You Entered Foo Title');
}
/** @test */
public function it_verifies_information_in_the_database()
{
$this->visit('database-test')
->type('Testing', 'name')
->press('Save to Database')
->verifyInDatabase('things', ['name' => 'Testing']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment