Testing higher-order Observables #144
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was implementing the
window()operator and I realized I've encountered a situation that wasn't tested before. That's higher-order Observables and in particular operators that emit Observables where I need to test that these Observables emit correct items themselves.This PR lets me write tests for
window()operator like the following:https://github.com/martinsik/RxPHP/blob/window-operator/test/Rx/Functional/Operator/WindowTest.php
The most important part is this:
There's a new
OnNextObservableNotificationthat automatically subscribes to an Observable and all items are recorded with timestamps relative to its parent. Then these automatic subscriptions are ignored by theColdObservable. I've actually spent quite some time scratching my head around how to implement this in the most comfortable and easy to use way. Ideally if I didn't need to think about it at all and use Observables just like any other values.If I didn't miss anything this should allow fluent porting from RxJS 5 marble tests (eg. window-spec.ts) where they treat Observables like values. For example this should work in RxPHP as well:
Using this with #133 shouldn't be any problem.
Also, I didn't need to modify any existing tests including those that use higher-order Observables as input such as
MergeAllTest.php.