vendredi 30 octobre 2015

Symfony Functional Testing not working when clicking links

i'm trying to write a functional test in which case i want a link to be clicked and make an assertion from the new page in order to check if the button redirects properly. My test case

public function testNavigationCustomersButton()
    {
        $client = static::createClient();
        $crawler = $client->request('GET', '/');
        $link = $crawler->selectLink('Customers')->link();
        $crawler = $client->click($link);
        $this->assertContains('Customers Managment - Index', $client->getResponse()->getContent());
    }

When i run the test and the $client->getResponse() is printed on the console i get the html from the index page , so i think that the link does not work properly. How can i use the crawler in order to click a link and make an assertion depending on the new loaded page?

Aucun commentaire:

Enregistrer un commentaire