Last active
July 10, 2018 16:33
-
-
Save laracasts/8161725 to your computer and use it in GitHub Desktop.
Transactions for functional/integration tests.
This file contains hidden or 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 ExampleTest extends TestCase { | |
public function setUp() | |
{ | |
parent::setUp(); | |
DB::beginTransaction(); | |
} | |
/** | |
* A basic functional test example. | |
* | |
* @return void | |
*/ | |
public function testShowsPosts() | |
{ | |
$title = 'Yay Great Post'; | |
// "Create" post | |
Post::create(compact('title')); | |
$crawler = $this->client->request('GET', 'posts'); | |
$this->assertEquals( | |
1, | |
count($crawler->filter("body:contains('{$title}')")), | |
"Expected to see the text '{$title}' within a body element." | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment