<?php
namespace App\Tests\Controller;

use App\Controller\HelloController;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class HelloControllerTest extends WebTestCase
{
    public function testHelloRandomRoute()
    {
        $client = static::createClient();

        $crawler = $client->request("GET", "/helloRandom");

        $this->assertEquals(200, $client->getResponse()->getStatusCode());
        $this->assertStringContainsString("Hello ", $crawler->filter("h1")->text());
    }

    function testRandomNameGenerator()
    {
        $Name = HelloController::generateRandomName();
        $this->assertGreaterThan(1, strlen($Name));
    }
    public function testHelloName()
    {
        $client = static::createClient();

        $crawler = $client->request("GET", "/hello/Albus Perceval Wulfric Brian Dumbledore");

        $this->assertEquals(200, $client->getResponse()->getStatusCode());
        $this->assertStringContainsString("Hello Albus Perceval Wulfric Brian Dumbledore", $crawler->filter("h1")->text());
    }

    public function testHelloName2()
    {
        $client = static::createClient();

        $crawler = $client->request("GET", "/hello");

        $this->assertEquals(200, $client->getResponse()->getStatusCode());
        $this->assertStringContainsString("Hello ", $crawler->filter("h1")->text());
    }

}

