-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Feature: Adding StreamFilterTrait #6112
Conversation
Can you rebase to remove unrelated commits? |
I may be doing something wrong, but the PR has already been rebased. |
Did you do this?
@iRedds You're right. This brach has been rebased. |
Okay, fixed. |
Probably you created this PR branch from |
I've rebased onto upstream/develop. Now the new PR should be based on 4.3 and rebased on upstream/4.3? |
Sorry, the manual is not updated yet. Now we have two development branches,
This is so that bug fix versions can be released quickly.
The bug fix only PRs are based on |
You came up with something complicated ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems handy!
My suggestion: Can we make StreamOutput
to OutputStream
and StreamError
to ErrorStream
, i.e. appendStreamOutputFilter
vs appendOutputStreamFilter
? In my opinion, that will make the methods sound more "natural" and would make the methods descriptive of their names (e.g., appendOutputStreamFilter
is "append filter to the output stream").
@paulbalandan I agree. It really does sound better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! I always end up copying the framework test methods into projects when I need buffer testing.
My only thought: should automate stream registration when using the trait? Or stream removal? Or both?
https://codeigniter4.github.io/userguide/testing/overview.html#traits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also update this: https://codeigniter4.github.io/userguide/testing/overview.html#stream-filters
@paulbalandan already added. f67d745 I'm not good at github actions, but if I'm right, the 4.3 branch won't show up here. Moreover, it is still PR. |
@MGatner If it's only about registering a filter class, then I think it's a good idea. Up: the idea is good, but if the CodeIgniter4/tests/system/Commands/ConfigGeneratorTest.php Lines 24 to 30 in 5eb41d6
So I want to hear more opinions on your proposal as a whole. |
I think it is a bug that does not call parent. Are there use cases that we don't want to append/remove the stream filters automatically? |
@kenjis I can't think of a situation yet that would cause problems. That's why I asked for an opinion. |
I guess the docs aren't very clear, probably my fault. But traits can provide their own methods that will be called automatically: I think since most cases if a developer is using the trait they want this baseline we should consider making that happen without intervention. Edit: see |
@MGatner Thanks for the clarification, but I initially understood your idea of trait preconfiguration. |
Please add: --- a/user_guide_src/source/changelogs/index.rst
+++ b/user_guide_src/source/changelogs/index.rst
@@ -12,6 +12,7 @@ See all the changes.
.. toctree::
:titlesonly:
+ v4.3.0
v4.2.1
v4.2.0
v4.1.9 |
Sorry for a comment after a comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kenjis making you work for it 😂
This is looking great and I'm excited about the feature. I'm good with it whenever you all think it is ready.
dc41e45
to
50c3a14
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@iRedds Thank you! |
Description
StreamFilterTrait trait, which correctly adds and removes filters for capturing stream output, since the current implementation in the tests is not correct enough in my opinion.
Overview of methods
StreamFilterTrait::registerStreamFilterClass()
Registering a filter to capture streams.StreamFilterTrait::appendStreamOutputFilter()
Adding a filter to the output stream.StreamFilterTrait::appendStreamErrorFilter()
Adding a filter to the error stream.StreamFilterTrait::removeStreamOutputFilter()
Removing the filter from the output stream.StreamFilterTrait::removeStreamErrorFilter()
Removing the filter from the error stream.StreamFilterTrait::getStreamFilterBuffer()
Get the captured data from the buffer.StreamFilterTrait::resetStreamFilterBuffer()
Reset captured data.Checklist: