chain() public static method

Generate a chain class with the current rules of the mock.
public static chain ( mixed $mock ) : object
$mock mixed Mock object, namespaced static mock, namespaced function name.
return object MockerChain instance
Example #1
0
 public function testFilterDispatcherGensCorrectTransaction()
 {
     // Setup
     $params = array('request' => new stdClass());
     $params['request']->params = array('action' => 'foobar');
     Mocker::overwriteFunction('li3_newrelic\\extensions\\get_class', function () {
         return 'foo\\bar\\BazController';
     });
     NewrelicMock::applyFilter('shouldRun', function ($self, $params, $chain) {
         return false;
     });
     // Call it
     NewrelicMock::filterDispatcher(new stdClass(), $params);
     $chain = Mocker::chain('li3_newrelic\\extensions\\newrelic\\Mock');
     // Assert
     $chain->called('__callStatic')->with('name_transaction', array('Baz/foobar'));
     $this->assertTrue($chain->success());
 }
Example #2
0
 public function testRespondsToMagic()
 {
     $chain = Mocker::chain(array());
     $this->assertTrue($chain->respondsTo('gt'));
     $this->assertTrue($chain->respondsTo('lt'));
     $this->assertFalse($chain->respondsTo('et'));
 }
Example #3
0
 public function testChainReturnsMockerChain()
 {
     $this->assertInstanceOf('lithium\\test\\MockerChain', Mocker::chain(new \stdClass()));
 }
Example #4
0
 public function testNotCreateCacheWhenTestingEnabled()
 {
     $adapter = 'lithium\\tests\\mocks\\core\\mockAdapter\\Mock';
     $adapter::config(array('default' => array(array('adapter' => 'Memory'))));
     $adapter::enabled('default');
     $chain = Mocker::chain($adapter);
     $this->assertFalse($chain->called('adapter')->success());
 }
 public function testChainReturnsMockerChain()
 {
     $this->assertTrue(Mocker::chain(new \stdClass()) instanceof \lithium\test\MockerChain);
 }
Example #6
0
 public function testRead()
 {
     $this->_createObjects();
     $this->charizard->connection->applyFilter('get', function () {
         return json_encode(array('responseHeader' => array('status' => 0), 'grouped' => array('master_id' => array('matches' => 1234, 'ngroups' => 5678, 'groups' => array('foo', 'bar', 'baz')))));
     });
     $this->charizard->read($this->query);
     $this->assertTrue(Mocker::chain($this->charizard)->called('item')->with(null, array('foo', 'bar', 'baz'), array('stats' => array('matches' => 1234, 'ngroups' => 5678, 'count' => 5678, 'facet_counts' => array(), 'facets' => array()), 'class' => 'set'))->eq(1)->success());
 }