Skip to content

Conversation

@MGatner
Copy link
Member

@MGatner MGatner commented Nov 6, 2020

Description
Filters can return a ResponseInterface directly, which bypasses feature testing's buffer handling and causes CLI output. This PR adds a new MockFilters which intercepts responses and starts a new buffer predictively to prevent output (the buffer will be closed shortly after by FeatureTestTrait.

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • n/a User guide updated
  • Conforms to style guide

@MGatner
Copy link
Member Author

MGatner commented Nov 6, 2020

Probably finding a way to incorporate MockResponse into feature tests would be better but our whole FeatureTestTrait revolves around gathering buffered output, so mark it as "to do" for somewhere down the road...

Copy link
Member

@paulbalandan paulbalandan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a few tests for this.

Quick question. Since this is preventing output to be printed in the CLI, does the CITestStreamFilter can't do the same? In the spark commands tests we use that class to capture output printed in the CLI so I am thinking maybe it can do the same here.

@MGatner
Copy link
Member Author

MGatner commented Nov 7, 2020

That's a good question: I'm not sure. The problem isn't so much that there is output, but rathe that feature tests may have endpoints which use Filters that return a Response directly. In CodeIgniter.php if this is detected it will send the response immediately, causing it to be written out.

I think we would still need some way to interrupt that process, since plenty of feature tests write output, just not directly. But I will look into it more.

@MGatner
Copy link
Member Author

MGatner commented Nov 7, 2020

Actually digging through the "why" right now I think that the filter response in CodeIgniter.PHP should be amended to respect $returnResponse.

@MGatner MGatner mentioned this pull request Nov 7, 2020
4 tasks
@MGatner
Copy link
Member Author

MGatner commented Nov 8, 2020

Superseded by a PR with a more appropriate solution.

@MGatner MGatner closed this Nov 8, 2020
@MGatner MGatner deleted the filters-test branch January 4, 2022 15:21
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

Successfully merging this pull request may close these issues.

2 participants