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

Bug: Risky feature tests with Controller returns #3063

Closed
MGatner opened this issue Jun 4, 2020 · 4 comments
Closed

Bug: Risky feature tests with Controller returns #3063

MGatner opened this issue Jun 4, 2020 · 4 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@MGatner
Copy link
Member

MGatner commented Jun 4, 2020

Describe the bug
FeatureTestCase allows simulating an app run and gathering the output for testing purposes. If a controller returns the output instead of echoing it (e.g. return view('Home');) it isn't cleaning the output buffer correctly causing risky tests with the following warning:

Test code or tested code did not (only) close its own output buffers

CodeIgniter 4 version
develop latest

Affected module(s)
FeatureTestTrait

Expected behavior, and steps to reproduce if appropriate
Controller:

class Home extends BaseController
{
	public function index()
	{
		return view('home');
	}

Test:

class HomeTest extends FeatureTestCase
{
	public function testGetHome()
	{
		$result = $this->get('/');

		$result->assertStatus(200);

Context

  • OS: Linux
  • Web server: Apache
  • PHP version: 7.3
@MGatner MGatner added the bug Verified issues on the current code behavior or pull requests that will fix them label Jun 4, 2020
@MGatner
Copy link
Member Author

MGatner commented Jun 5, 2020

@samsonasik any chance this is an easy fix similar to #2551 or #2625? I honestly have dug into it yet but won't have a chance to today.

@samsonasik
Copy link
Member

I tried do buffering check in the FeatureTestCase class if i remember correctly, but not work. I hope I can re-check again if I have a chance.

MGatner added a commit to MGatner/CodeIgniter4 that referenced this issue Jun 10, 2020
@samsonasik
Copy link
Member

@MGatner should can be closed in favor of #3083 ?

@MGatner
Copy link
Member Author

MGatner commented Jun 16, 2020

Yes! Thanks for catching that. I had a “fixes ____” commit but I must have overwritten it when I force pushed.

@MGatner MGatner closed this as completed Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

2 participants