Skip to content

Instantly share code, notes, and snippets.

@muhamed-didovic
Forked from JeffreyWay/example.php
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save muhamed-didovic/80fb0551cd9493af488b to your computer and use it in GitHub Desktop.

Select an option

Save muhamed-didovic/80fb0551cd9493af488b to your computer and use it in GitHub Desktop.
<?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