Rx\Functional\Operator\CatchErrorTest::catchError_Nested_OuterCatches PHP Method

catchError_Nested_OuterCatches() public method

    public function catchError_Nested_OuterCatches()
    {
        $error = new \Exception();
        $firstHandlerCalled = false;
        $secondHandlerCalled = false;
        $o1 = $this->createHotObservable([onNext(150, 1), onNext(210, 2), onError(215, $error)]);
        $o2 = $this->createHotObservable([onNext(220, 3), onCompleted(225)]);
        $o3 = $this->createHotObservable([onNext(220, 4), onCompleted(225)]);
        $results = $this->scheduler->startWithCreate(function () use($o1, $o2, $o3, &$firstHandlerCalled, &$secondHandlerCalled) {
            return $o1->catchError(function () use($o2, &$firstHandlerCalled) {
                $firstHandlerCalled = true;
                return $o2;
            })->catchError(function () use($o3, &$secondHandlerCalled) {
                $secondHandlerCalled = true;
                return $o3;
            });
        });
        $this->assertMessages([onNext(210, 2), onNext(220, 3), onCompleted(225)], $results->getMessages());
        $this->assertTrue($firstHandlerCalled);
        $this->assertFalse($secondHandlerCalled);
    }