I have a question concerning the functional test in Silex/PHPUnit.
require_once '/var/www/silex/vendor/autoload.php';
class MyTest extends Silex\WebTestCase{
protected $app;
public function createApplication() {
$this->app = require 'app.php';
return $this->app;
}
public function testInitialPage(){
$client = $this->createClient();
$crawler = $client->request('GET', '/login');
$this->assertTrue($client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('html:contains("Login")'));
$this->assertCount(1, $crawler->filter('form'));
$this->app['session']->set('userid', X);
$this->app['session']->set('username', 'X');
$this->app['session']->set('isadmin', true);
$crawler = $client->request('GET', '/');
$this->assertTrue($client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('html:contains("Cred")'));
}
public function testAdd() {
$client = $this->createClient();
$crawler = $client->request('GET', '/');
$this->assertTrue($client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('html:contains("Cred")'));
}
This should be the first "test" but every time I run it, the testInitialPage()
method runs and I do not get any Errors.
But in testAdd()
I get a failure ' No route found for "GET /" '
For me it seems that $app (and routing) does not exist anymore in the second Method "testAdd()"
Does anybody have a hint for me how to set a a right Functional Testing system?