<?php

namespace Bodyrep\Tests\Controller;

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

class AuthControllerTest extends WebTestCase
{
    public function testIndex()
    {
        $client = static::createClient();
        $client->followRedirects(true);
        $crawler = $client->request('GET', '/u/login');

        $this->assertTrue($crawler->filter('html:contains("Username")')->count() > 0);
    }

    public function testLogin()
    {
        $client = static::createClient();
        $client->followRedirects(true);
        $crawler = $client->request('GET', '/u/login');


        $form = $crawler->selectButton('loginbtn')->form();
        $crawler = $client->submit($form, array(
            '_username' => 'alexl',
            '_password' => 'd559ko54'
        ));

        $this->assertTrue($crawler->filter('html:contains("Member")')->count() > 0);
    }

    public function testLogout()
    {
        $client = static::createClient();
        $client->followRedirects(true);

        $crawler = $client->request('GET', '/u/logout');

        $this->assertTrue($crawler->filter('html:contains("Landing")')->count() > 0);
    }
    
}
?>
