Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emil-nasso/b0c74e424b402389bde15ec46e67df12 to your computer and use it in GitHub Desktop.
Save emil-nasso/b0c74e424b402389bde15ec46e67df12 to your computer and use it in GitHub Desktop.
// tests/AppBundle/Controller/PostControllerTest.php
namespace Tests\AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class PostControllerTest extends WebTestCase
{
public function testShowPost()
{
$client = static::createClient();
$mock = /** mocked version of the service with data relevant to this test**/
$client->getContainer()->set('app.externalapi', $mock)
$crawler = $client->request('GET', '/post/hello-world');
$this->assertGreaterThan(
0,
$crawler->filter('html:contains("Hello World")')->count()
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment