/**
  * @test
  */
 public function it_creates_a_sequence_with_any_expectation()
 {
     $sequence = SequenceBuilder::create()->expect()->quantity()->any()->token(T_WHITESPACE, "\n")->end()->end()->build();
     $expectedSequence = new ForwardSequence();
     $expectedSequence->addExpectation(new Quantity(new ExactMatch(T_WHITESPACE, "\n"), null, null));
     $this->assertEquals($expectedSequence, $sequence);
 }
 /**
  * @test
  */
 public function it_fails_when_peek_is_called_but_end_of_sequence_is_reached()
 {
     $forwardSequence = new ForwardSequence();
     $this->setExpectedException('Matthias\\Codesniffer\\Sequence\\Exception\\EndOfSequence');
     $forwardSequence->peek();
 }
 /**
  * @test
  * @dataProvider tokensProvider
  */
 public function it_matches_a_complicated_set_of_expectations(array $expectations, array $tokens, $expectedToMatch)
 {
     $sequence = new ForwardSequence($expectations);
     $this->assertSame($expectedToMatch, $sequence->matches($tokens, 0));
 }
 /**
  * @test
  * @dataProvider tokensProvider
  */
 public function it_matches_succeeding_tokens(array $expectations, array $tokens, $tokenIndex, $expectedToMatch)
 {
     $sequence = new ForwardSequence(array(new Succeeding($expectations)));
     $this->assertSame($expectedToMatch, $sequence->matches($tokens, $tokenIndex));
 }
 /**
  * @test
  * @dataProvider tokensProvider
  */
 public function it_matches_a_number_of_tokens(ExpectationInterface $innerExpectation, $minimum, $maximum, array $tokens, $tokenIndex, $expectedToMatch)
 {
     $sequence = new ForwardSequence();
     $sequence->addExpectation(new Quantity($innerExpectation, $minimum, $maximum));
     $this->assertSame($expectedToMatch, $sequence->matches($tokens, $tokenIndex));
 }
 /**
  * @test
  * @dataProvider tokensProvider
  */
 public function it_matches_exactly_one_token($tokens, $tokenIndex, $expectedToMatch)
 {
     $sequence = new ForwardSequence();
     $sequence->addExpectation(new ExactMatch(T_WHITESPACE));
     $this->assertSame($expectedToMatch, $sequence->matches($tokens, $tokenIndex));
 }