-
-
Save muhamed-didovic/80fb0551cd9493af488b to your computer and use it in GitHub Desktop.
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 | |
| // https://packagist.org/packages/way/laravel-test-helpers | |
| use Way\Tests\Factory; | |
| class ExampleTest extends TestCase { | |
| public function test_fetches_all_posts() | |
| { | |
| Factory::create('Post', ['title' => 'My Post']); | |
| $this->call('GET', 'posts'); | |
| $this->assertViewHas('posts'); | |
| $this->see('My Post', 'h1'); | |
| } | |
| // Add this to TestCase or to a trait | |
| protected function see($text, $element = 'body') | |
| { | |
| $crawler = $this->client->getCrawler(); | |
| $matches = $crawler->filter("{$element}:contains('{$text}')"); | |
| $this->assertGreaterThan(0, count($matches), "Expected to see the text '$text' within an '$element' element."); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment