public function testMultipleCallsWithArgsAndSpecificCalled()
 {
     $mock = new \lithium\tests\mocks\test\mockStdClass\Mock();
     $mock->method1('foo', 'bar');
     $mock->method1('foo', 'bar');
     $mock->method1('foo', 'bar');
     $mock->method2('baz');
     $mock->method2('baz');
     $mock->method1();
     $chain = Mocker::chain($mock);
     $this->assertTrue($chain->called('method1')->with('foo', 'bar')->eq(3)->success());
     $this->assertTrue($chain->called('method2')->with('baz')->eq(2)->success());
     $this->assertTrue($chain->called('method1')->with()->eq(1)->success());
     $this->assertTrue($chain->called('method1')->with('foo', 'bar')->eq(3)->called('method2')->with('baz')->eq(2)->called('method1')->with()->eq(1)->success());
 }
예제 #2
0
 public function testMagicCallGetStoredResultsWhenCalledIndirectly()
 {
     $obj = new \lithium\tests\mocks\test\mockStdClass\Mock();
     $obj->methodBar();
     $results = Mocker::mergeResults($obj->results, $obj::$staticResults);
     $this->assertArrayHasKey('__call', $results);
     $this->assertCount(2, $results['__call']);
 }
 public function testSkipByReference()
 {
     $stdObj = new \lithium\tests\mocks\test\mockStdClass\Mock();
     $stdObj->foo = 'foo';
     $originalData = $stdObj->data();
     $stdObj->applyFilter('data', function ($self, $params, $chain) {
         return array();
     });
     $nonfilteredData = $stdObj->data();
     $this->assertIdentical($originalData, $nonfilteredData);
 }