Skip to content

Instantly share code, notes, and snippets.

@isidromerayo
Last active October 13, 2015 15:18
Show Gist options
  • Save isidromerayo/4215490 to your computer and use it in GitHub Desktop.
Save isidromerayo/4215490 to your computer and use it in GitHub Desktop.
Symfony2 WebTestCase client status code 200
<?php
namespace Hcuv\TiendaBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class DefaultControllerTest extends WebTestCase
{
public function testPortadaTienda()
{
$client = static::createClient();
$ciudad = 'barcelona';
$tienda = 'pub-consectetur';
$texto = 'Pub Consectetur';
$crawler = $client->request('GET', '/' . $ciudad . '/tiendas/' . $tienda);
$messageError = '';// $crawler->filter('div.text_exception h1')->text();
$this->assertEquals(200, $client->getResponse()->getStatusCode(), $messageError);
// article
$this->assertTrue($crawler->filter('html:contains("' . $texto . '")')->count() > 0);
// aside
$this->assertTrue($crawler->filter('html:contains("Otras tiendas en")')->count() > 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment