Summary
This chapter covered unit testing code written using PHPUnit with utilities provided by the RxPHP package.
Most importantly, we went through the doOn*()
operators and the basics of unit testing with PHPUnit, and the problems we need to be aware of when unit testing asynchronous code. Next, we went in-depth into which classes aimed at unit testing are provided by RxPHP, how to use each of them, and which problems they solve. In particular, these were the VirtualTimeScheduler
, HotObservable
,
ColdObservable
, TestScheduler
, and FunctionalTestCase
classes. In addition to this, we wrote example SumOperator
and ForkJoinObservable
classes to demonstrate how important it is to test that messages are emitted and received at the correct times.
In the following chapter, we'll have a deeper look at event loops in PHP and we'll introduce a more advanced concept of higher-order Observables in RxPHP.