/**
  * @expectedException        \PHPUnit_Framework_ExpectationFailedException
  * @expectedExceptionMessage wrong argument
  */
 public function testWrongArguments()
 {
     $builder = new Builder();
     $builder->expects($this->exactly(2))->with('first method call matcher')->willReturnSelf();
     $builder->expects($this->once())->with('second method call matcher')->willReturn('second return');
     $dummy = $this->getMock(\stdClass::class, ['test']);
     $dummy->expects($builder->matcher())->method('test')->will($builder->mapper());
     $this->assertSame($dummy, $dummy->test('first method call matcher'));
     $this->assertSame($dummy, $dummy->test('first method call matcher'));
     $this->assertSame('second return', $dummy->test('wrong argument'));
 }
 public function testSolution()
 {
     $builder = new Builder();
     $builder->expects($this->exactly(2))->with(new DummyValueHolder('aaa'))->willReturnSelf();
     $builder->expects($this->once())->with('second method call matcher')->willReturn('second return');
     $builder->expects($this->exactly(2))->with('third method call matcher')->willReturn('third return');
     $dummy = $this->getMock(\stdClass::class, ['test']);
     $dummy->expects($builder->matcher())->method('test')->will($builder->mapper());
     $this->assertSame($dummy, $dummy->test(new DummyValueHolder('aaa')));
     $this->assertSame($dummy, $dummy->test(new DummyValueHolder('aaa')));
     $this->assertSame('second return', $dummy->test('second method call matcher'));
     $this->assertSame('third return', $dummy->test('third method call matcher'));
     $this->assertSame('third return', $dummy->test('third method call matcher'));
 }
 /**
  *
  */
 public function testPath()
 {
     $builder = new Builder();
     $builder->expects($this->exactly(2))->with('first method call matcher')->willReturn('first random-string');
     $builder->expects($this->once())->with('second method call matcher')->willReturn('second random-string');
     $matcher = $builder->matcher();
     $returnMapper = $builder->mapper();
     $invocation = $this->createInvocation(['first method call matcher']);
     $matcher->matches($invocation);
     $matcher->invoked($invocation);
     $this->assertSame('first random-string', $returnMapper->invoke($invocation));
     $invocation = $this->createInvocation(['first method call matcher']);
     $matcher->matches($invocation);
     $matcher->invoked($invocation);
     $this->assertSame('first random-string', $returnMapper->invoke($invocation));
     $invocation = $this->createInvocation(['second method call matcher']);
     $matcher->matches($invocation);
     $matcher->invoked($invocation);
     $this->assertSame('second random-string', $returnMapper->invoke($invocation));
     $matcher->verify();
     $this->assertSame('', $returnMapper->toString());
 }