Beta J-602 !
Logo PhpUnit

Phpunit - testing content's page

Par Julie, le 23/06/2018

Testing string or tag in a page

<?php

namespace App\Tests\Controller\Core;


use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Response;

class SecurityControllerTest extends WebTestCase
{
    private $client = null;

    public function setUp() {
        $this->client = static::createClient();
    }

    public function testLoginPageContent()
    {
        $crawler = $this->client->request('GET', '/security/login');

        $this->assertSame(1, $crawler->filter('html:contains("Welcome on my app")')->count());
    }

    public function testForgottenPassword()
    {
        $crawler = $this->client->request('GET', '/security/forgotten-password');
        $this->assertSame(1, $crawler->filter('form')->count());
    }
}

Cet article est paru dans les catégories suivantes: Tests