Bonjour,
je commence à écrire des tests fonctionnels pour mon site et j'ai cette erreur:
Circular reference detected in "/var/www/html/Virgule/app/config/routing_dev.yml" ("/var/www/html/Virgule/app/config/routing_dev.yml" > "/var/www/html/Virgule/app/config/routing.yml" > "/var/www/html/Virgule/src/Virgule/Bundle/MainBundle/Controller/" > "/var/www/html/Virgule/app/config/routing_dev.yml").
Erreur que je n'ai pas quand je parcours le site, que ce soit en mode dev ou prod.
Voici ma config :
routing.yml
virgule_main_bundle_security:
resource: "@VirguleSecurityBundle/Controller/"
type: annotation
prefix: /
virgule_main_bundle:
resource: "@VirguleMainBundle/Controller/"
type: annotation
prefix: /
login_check:
pattern: /login_check
routing_dev.yml:
_assetic:
resource: .
type: assetic
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_main:
resource: routing.yml
Le reste des routes est défini dans les controller avec des annotations.
Et mon test:
<?php
namespace Virgule\Bundle\SecurityBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class SecurityControllerTest extends WebTestCase {
private $crawler;
public function testCompleteScenario() {
// Create a new client to browse the application
$client = static::createClient();
// Check default URL
$crawler = $client->request('GET', '/');
file_put_contents("/home/guillaume/git/Virgule/response.html", $client->getResponse());
$this->assertTrue($client->getResponse()->isRedirection('/login')); // --------------------------------------> ligne 17
$crawler = $client->request('GET', '/login');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
// Test wrong credentials
$this->fillAndSubmitLoginForm($client, $crawler, 'Toto', 'Toto');
$crawler = $client->followRedirect();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertTrue($crawler->filter('div:contains("identification a échoué")')->count() > 0);
$this->fillAndSubmitLoginForm($client, $crawler, 'prof1', 'password');
$crawler = $client->followRedirect();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertTrue($client->getResponse()->isRedirection('/welcome'));
}
private function fillAndSubmitLoginForm($client, $crawler, $username, $password) {
// Fill in the form and submit it
$form = $crawler->selectButton('Connexion')->form(array(
'_username' => $username,
'_password' => $password
));
$client->submit($form);
}
}
?>
Erreur à l'exécution du test:
14) Virgule\Bundle\SecurityBundle\Tests\Controller\SecurityControllerTest::testCompleteScenario
Failed asserting that false is true.
/var/www/html/Virgule/src/Virgule/Bundle/SecurityBundle/Tests/Controller/SecurityControllerTest.php:17
De quoi cela peut-il venir ?
Merci