Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot modify header information - headers already sent #418

Open
rlefever opened this issue Feb 4, 2025 · 0 comments
Open

Cannot modify header information - headers already sent #418

rlefever opened this issue Feb 4, 2025 · 0 comments

Comments

@rlefever
Copy link

rlefever commented Feb 4, 2025

Using CI 3.1.13, PHP 7.4, PHPUnit 9.6, ci-phpunit-test freshly installed.

I have read this Issue 242 and it seems related, but cannot figure out the solution.

When I load my ts_helper via config/autoloader I get:

PHPUnit 9.6.22 by Sebastian Bergmann and contributors.

Warning: No code coverage driver available

.E........... 13 / 13 (100%)

Time: 00:00.309, Memory: 10.00 MB

There was 1 error:

  1. Main_test::test_index
    RuntimeException: Cannot modify header information - headers already sent by (output started at /web/app-v1/helpers/ts_helper.php:1) on line 63 in file /web/app-v1/tests/_ci_phpunit_test/replacing/helpers/url_helper.php

/web/app-v1/tests/_ci_phpunit_test/CIPHPUnitTestCase.php:180
/web/app-v1/tests/_ci_phpunit_test/replacing/helpers/url_helper.php:63
/web/app-v1/controllers/Main.php:18
/web/app-v1/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:373
/web/app-v1/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:297
/web/app-v1/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:160
/web/app-v1/tests/_ci_phpunit_test/CIPHPUnitTestCase.php:155
/web/app-v1/tests/controllers/Main_test.php:21

The Main/index only redirects to Main/login

I have commented everything in the ts_helper and the error continues.

Another point that may pertain to this is I am running the tests with ENVIRONMENT = 'development' as my intent is to use the test first coding method.

Changing url_helper line 61 to if( ! (ENVIRONMENT == 'testing' || ENVIRONMENT == 'development')) causes all the tests to be skipped apparently as no dots, or other responses are displayed.

Changing ENVIRONMENT = 'testing' does seem to correct the issue. Test run and the error is shown. Not sure of the implications of developing in 'test' vs 'development' will be.

The link for phpunit.readthedocs.io about @runTestsInSeparateProcesses and @runInSeparateProcess in the comments leads to a 404.

The function CIPPUnitTestCase::isTestingEnv() line 469 added really didn't change the functionality of the original poster's issues and still only looks for testing. Possible change this to !== 'production'?

With the ENVIRONMENT back to 'development' and uncommenting everything in ts_helper, that change seems to fix the issue I am seeing.

Hope this helps someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant