Skip to content

Instantly share code, notes, and snippets.

@NandoKstroNet
Created July 26, 2017 13:36
Show Gist options
  • Save NandoKstroNet/42eab6903705f8048993fde6f702350e to your computer and use it in GitHub Desktop.
Save NandoKstroNet/42eab6903705f8048993fde6f702350e to your computer and use it in GitHub Desktop.
Conteúdo criado na série sobre testes com Silex pela Code Experts Learning https://codeexpertslearning.com.br
<?php
use Silex\WebTestCase;
class RoutesTest extends WebTestCase
{
public function createApplication()
{
return require ROOT_DIR . '/app.php';
}
public function testIndexRoute()
{
$client = $this->createClient();
$crawler = $client->request('GET', '/');
$this->assertTrue($client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('h1:contains("Testando")'));
}
public function testNewsRouteWithDynamicParameter()
{
$slug = 'noticia-teste';
$client = $this->createClient();
$crawler = $client->request('GET', '/noticia/' . $slug);
$this->assertTrue($client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('h1:contains("Noticia: ' . $slug . '")'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment