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: FeatureTest dies when throws RedirectException/cached page #4288

Closed
kenjis opened this issue Feb 15, 2021 · 5 comments · Fixed by #4315
Closed

Bug: FeatureTest dies when throws RedirectException/cached page #4288

kenjis opened this issue Feb 15, 2021 · 5 comments · Fixed by #4315
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@kenjis
Copy link
Member

kenjis commented Feb 15, 2021

Describe the bug
CodeIgniter::run() may call exit() and if you hit the point, FeatureTest (phpunit) dies.

$this->callExit(EXIT_SUCCESS);

$this->callExit(EXIT_SUCCESS);

protected function callExit($code)
{
// @codeCoverageIgnoreStart
exit($code);
// @codeCoverageIgnoreEnd
}

CodeIgniter 4 version
develop branch

Affected module(s)
CodeIgniter.php, Tests

Expected behavior, and steps to reproduce if appropriate
phpunit does not die.

Context

  • OS: [macOS 10.15.7]
  • Web server [n/a]
  • PHP version [7.4.15]
@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Feb 15, 2021
@MGatner
Copy link
Member

MGatner commented Feb 16, 2021

The method description says

Made into a separate method so that it can be mocked during testing without actually stopping script execution.

Is the issue that this mocking is not happening by default for Feature Test Cases?

@kenjis
Copy link
Member Author

kenjis commented Feb 19, 2021

@MGatner Yes.

See

$ composer test
> phpunit
PHPUnit 9.5.2 by Sebastian Bergmann and contributors.

.. (phpunit died)

@MGatner
Copy link
Member

MGatner commented Feb 20, 2021

We have system/Test/Mock/MockCodeIgniter.php but I see it isn't being used. It isn't immediately apparent to me how we would inject that during CIUnitTest but I believe that is the solution.

@kenjis
Copy link
Member Author

kenjis commented Feb 21, 2021

@MGatner Thank you for the info.
I will look into it.

@kenjis
Copy link
Member Author

kenjis commented Feb 21, 2021

See #4315

MGatner added a commit that referenced this issue Feb 26, 2021
Fix #4288 FeatureTest dies when throws RedirectException/cached page
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

Successfully merging a pull request may close this issue.

2 participants