1

I am trying to create acceptance tests for my Symfony 3 application, but it is not working. It always show me one error:

AdminFamilyTestCest: Test admin\farm page of my site Test tests\acceptance\AdminFamilyTestCest.php:testFamilyPage Step Can see in title "Family" Fail Failed asserting that
/admin/families/ --> Failed to start the session because headers have already been sent by "C:\wamp64\www\farm\vendor\symfony\phpunit-bridge\SymfonyTestsListener.php" at line 77. (500 Internal Server Error) OK Need support? Failed to start the session because headers have already been sent by "C:\wamp64\www\farm\vendor [Content too long to display. See complete response in 'C:\wamp64\www\farm\tests/_output\' directory] --> contains "#logout".

Scenario Steps:

  1. $I->see("#logout")
  2. $I->canSeeInTitle("Family")
  3. $I->amOnPage("/admin/families/")
  4. $I->click("Log in")
  5. $I->fillField("_password","admin")
  6. $I->fillField("_username","admin")

FAILURES! Tests: 1, Assertions: 3, Failures: 2.

Shorter message is: Failed to start the session because headers have already been sent.

Code of my tests:

class AdminFamilyTestCest
{
    public function testFamilyPage(AcceptanceTester $I)
    {
        $I->wantToTest('Admin\Farm page of my site');
        $I->amOnPage('/login');
        $I->see('Log in');
        $I->fillField('_username', 'admin');
        $I->fillField('_password', 'admin');
        $I->click('Log in');
        $I->amOnPage('/admin/families/');
        $I->canSeeInTitle('Family');
        $I->see('#logout');
        $I->amOnPage('/logout');
        $I->amOnPage('/login');
        $I->seeInTitle('Welcome!');
    }
}

Test is very simple, but I don't know why the error happens.

1
  • Look at tests/_output/AdminFamilyTestCest.testFamilyPage.html file and read a complete error message. It will tell you what code is making the output. This is an application error, not a Codeception error. Commented Oct 3, 2016 at 15:39

1 Answer 1

3

The root cause of your issue is that some piece of code is using header() function and sending output directly.

To be able to use Symfony module of Codeception all output and headers must be set using Symfony response object. If that can not be achieved, the alternative approach is to use PhpBrowser or WebDriver modules.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.