Created
February 19, 2013 16:23
-
-
Save petersuhm/4987406 to your computer and use it in GitHub Desktop.
Simple Laravel 4 integration test, for testing a todo list application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TodoItemTest extends TestCase { | |
public function testCreateTodoItem() | |
{ | |
// Visit create action and get crawler instance | |
$crawler = $this->client->request('GET', '/todo-items/create'); | |
// Check that request returned 200 | |
$this->assertTrue($this->client->getResponse()->isOk()); | |
// Use selectButton to grap form element and fill in the task input | |
$form = $crawler->selectButton('submit')->form(array( | |
'task' => 'Test Task' | |
)); | |
// Submit the form | |
$this->client->request( | |
$form->getMethod(), | |
$form->getUri(), | |
$form->getValues() | |
); | |
// Follow redirect to index action and get new crawler instance | |
$crawler = $this->client->followRedirect(); | |
// Check that redirect returned 200 | |
$this->assertTrue($this->client->getResponse()->isOk()); | |
// Check that the new todo item is present | |
$this->assertCount(1, $crawler->filter('li:contains("Test Task")')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment