mardi 6 septembre 2016

Symfony2 acceptance test not working

At the moment, I am writing acceptance test cases for Symfony2 application. I am doing following.

namespace my\Bundle\ProjectBundle\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class DefaultControllerTest extends WebTestCase
{
    public function testIndex()
    {
        $client = static::createClient(array(),array('HTTPS' => true));

        $client->request('GET', '/');

        $this->assertEquals(200, $client->getResponse()->getStatusCode());
    }
}

But it cases is failing on looking into following log file.

app/logs/test.log

It appears that

[2016-09-06 12:56:58] request.CRITICAL: Uncaught PHP Exception PHPUnit_Framework_Error_Notice: "Undefined index: SERVER_PROTOCOL" at /var/www/src/my/Bundle/projectBundle/Helper/DataHelper.php line 139 {"exception":"[object] (PHPUnit_Framework_Error_Notice(code: 8): Undefined index: SERVER_PROTOCOL at /var/www/src/my/Bundle/projectBundle/Helper/DataHelper.php:139)"} []

It appears that $_SERVER variable is missing some values in it. Any clues or is there any better ways to write the test cases.

Aucun commentaire:

Enregistrer un commentaire