/**
  * Method to test removeInstance().
  *
  * @return void
  *
  * @covers Windwalker\DataMapper\DataMapperContainer::removeInstance
  */
 public function testRemoveInstance()
 {
     $mapperBackup = DataMapperContainer::getInstance('#__content');
     DataMapperContainer::removeInstance('#__content');
     $mappers = TestHelper::getValue('Windwalker\\DataMapper\\DataMapperContainer', 'instances');
     $this->assertArrayNotHasKey('#__content', $mappers);
     $this->assertNotSame($mapperBackup, DataMapperContainer::getInstance('#__content'));
 }
 /**
  * Call the DataMapper methods.
  *
  * @param   string  $name  Method name to call.
  * @param   array   $args  The arguments of this method.
  *
  * @return  mixed  Return value of the target method.
  */
 public static function __callStatic($name, $args)
 {
     if (empty($args[0]) || !is_string($args[0])) {
         throw new \InvalidArgumentException('First argument should be table name.');
     }
     $table = array_shift($args);
     $mapper = DataMapperContainer::getInstance($table);
     return call_user_func_array(array($mapper, $name), $args);
 }
 /**
  * Method to test __callStatic().
  *
  * @return void
  *
  * @covers Windwalker\DataMapper\DataMapperFacade::__callStatic
  */
 public function test__callStatic()
 {
     $mockDataMapper = $this->getMockBuilder('Windwalker\\DataMapper\\DataMapper')->disableOriginalConstructor()->setMethods(array('find', 'findOne'))->getMock();
     $mockDataMapper->expects($this->at(0))->method('find')->with(array('state' => 1), 'id desc', 0, 3)->willReturn(new DataSet());
     $mockDataMapper->expects($this->at(1))->method('findOne')->with(array('state' => 1), 'created desc')->willReturn(new Data());
     DataMapperContainer::setInstance('#__content', $mockDataMapper);
     DataMapperFacade::find('#__content', array('state' => 1), 'id desc', 0, 3);
     DataMapperFacade::findOne('#__content', array('state' => 1), 'created desc');
 }