Esempio n. 1
0
 /**
  * Tests creating a hamcrest adapter matcher
  */
 public function testHamcrestMatcher()
 {
     $matcher = $this->getMock('Hamcrest_Matcher');
     $matcher->expects($this->once())->method('matches')->with($this->equalTo('foo'))->will($this->returnValue(true));
     $retMatcher = $this->factory->createMatcher($matcher);
     $value = 'foo';
     $this->assertTrue($retMatcher->matches($value));
 }
Esempio n. 2
0
 public function testMatcherSetsNextMatcherInChain()
 {
     $matcher1 = Phake::mock('Phake_Matchers_IChainableArgumentMatcher');
     $matcher2 = Phake::mock('Phake_Matchers_IChainableArgumentMatcher');
     /* @var $newMatcher Phake_Matchers_IChainableArgumentMatcher */
     $this->factory->createMatcher($matcher2);
     $this->factory->createMatcher($matcher1, $matcher2);
     $this->assertNull($matcher2->getNextMatcher());
     Phake::verify($matcher1)->setNextMatcher(Phake::equalTo($matcher2));
 }
Esempio n. 3
0
 /**
  * Assigns a matcher to the captor.
  *
  * This allows an argument to only be captured if the argument meets a specific criteria. This
  * is useful if one method is called multiple times.
  *
  * The same matcher factory used by the verifier and stubber is used here.
  *
  * @param mixed $matcher
  *
  * @return Phake_Matchers_ArgumentCaptor the current instance
  */
 public function when($matcher)
 {
     $factory = new Phake_Matchers_Factory();
     $this->matcher = $factory->createMatcher($matcher);
     return $this;
 }