コード例 #1
0
 function testPatternMatchReturn()
 {
     $mock = new MockDummy();
     $mock->setReturnValue("aMethod", "aaa", array(new PatternExpectation('/hello/i')));
     $this->assertIdentical($mock->aMethod('Hello'), "aaa");
     $this->assertNull($mock->aMethod('Goodbye'));
 }
コード例 #2
0
 function testMethodInterference()
 {
     $mock = new MockDummy();
     $mock->setReturnValueAt(0, "anotherMethod", "aaa");
     $mock->setReturnValue("aMethod", "AAA");
     $this->assertIdentical($mock->aMethod(), "AAA");
     $this->assertIdentical($mock->anotherMethod(), "aaa");
 }
コード例 #3
0
ファイル: mock_objects_test.php プロジェクト: Zunair/xataface
 function testReturnFromSpecialMethod()
 {
     $mock = new MockDummy();
     $mock->setReturnValue('__get', '1st Return', array('first'));
     $mock->setReturnValue('__get', '2nd Return', array('second'));
     $this->assertEqual($mock->__get('first'), '1st Return');
     $this->assertEqual($mock->__get('second'), '2nd Return');
     if (phpversion() >= 5) {
         $this->assertEqual($mock->first, $mock->__get('first'));
         $this->assertEqual($mock->second, $mock->__get('second'));
     }
 }