/** * @test */ public function it_creates_a_sequence_with_a_range_expectation() { $sequence = SequenceBuilder::create()->lookingBackward()->expect()->quantity()->atLeast(2)->atMost(4)->token(T_WHITESPACE, "\n")->end()->end()->build(); $expectedSequence = new BackwardSequence(); $expectedSequence->addExpectation(new Quantity(new ExactMatch(T_WHITESPACE, "\n"), 2, 4)); $this->assertEquals($expectedSequence, $sequence); }
/** * @test * @dataProvider tokensProvider */ public function it_walks_backward_over_an_array_of_tokens($tokens, $tokenIndex, $expectedTokens) { $forwardSequence = new BackwardSequence(); $expectationSpy = new Spy(); $forwardSequence->addExpectation($expectationSpy); $forwardSequence->matches($tokens, $tokenIndex); $this->assertEquals($expectedTokens, $expectationSpy->getTokens()); }