Rx\Functional\Operator\SelectTest::map_with_index_completed PHP Method

map_with_index_completed() public method

    public function map_with_index_completed()
    {
        $xs = $this->createHotObservable([onNext(180, 5), onNext(210, 4), onNext(240, 3), onNext(290, 2), onNext(350, 1), onCompleted(400), onNext(410, -1), onCompleted(420), onError(430, new Exception())]);
        $invoked = 0;
        $results = $this->scheduler->startWithCreate(function () use($xs, &$invoked) {
            return $xs->mapWithIndex(function ($index, $x) use(&$invoked) {
                $invoked++;
                return $x + 1 + $index * 10;
            });
        });
        $this->assertMessages([onNext(210, 5), onNext(240, 14), onNext(290, 23), onNext(350, 32), onCompleted(400)], $results->getMessages());
        $this->assertSubscriptions([subscribe(200, 400)], $xs->getSubscriptions());
        $this->assertEquals(4, $invoked);
    }