/**
  * 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');
 }
 /**
  * testDeleteSetNull
  *
  * @return  void
  *
  * @covers  \Windwalker\Relation\Handler\OneToOneRelation::delete
  */
 public function testDeleteSetNull()
 {
     $location = $this->createTestTable(Action::SET_NULL);
     $location->load(5);
     $dataId = $location->data->id;
     $location->delete();
     $this->assertEquals(10, $dataId);
     $this->assertTrue(DataMapperFacade::findOne(static::TABLE_LOCATIONS, 5)->isNull());
     $this->assertNull(DataMapperFacade::findOne(static::TABLE_LOCATION_DATA, $dataId)->location_id);
 }
 /**
  * getInstalledLanguages
  *
  * @param   integer  $client
  *
  * @return  DataSet|Data[]
  * 
  * @since   2.1.5
  */
 public static function getInstalledLanguages($client = JClient::BOTH)
 {
     $client = strtolower($client);
     if ($client == 'site') {
         $client = JClient::SITE;
     } elseif ($client == 'admin' || $client == 'administrator') {
         $client = JClient::ADMINISTRATOR;
     } elseif ($client == 'both') {
         $client = JClient::BOTH;
     }
     $conditions = array('type' => 'language');
     if ($client != JClient::BOTH) {
         $conditions['client_id'] = $client;
     }
     $langs = DataMapperFacade::find('#__extensions', $conditions);
     return $langs;
 }
 /**
  * getSuperUserGroup
  *
  * @return  integer
  */
 protected function getSuperUserGroup()
 {
     $data = DataMapperFacade::findOne('#__assets', 1);
     $rules = json_decode($data->rules, true);
     if (!isset($rules['core.admin'])) {
         return static::SUPER_USER_GROUP_ID;
     }
     $ids = array_keys($rules['core.admin']);
     return array_shift($ids);
 }
 /**
  * testDelete
  *
  * @return  void
  *
  * @covers  \Windwalker\Relation\Handler\OneToManyRelation::delete
  */
 public function testDelete()
 {
     $mapper = $this->createTestMapper();
     $location = $mapper->findOne(1);
     $sakuraIds = $location->sakuras->id;
     $roseIds = $location->roses->id;
     $mapper->delete(1);
     $this->assertTrue(DataMapperFacade::findOne(static::TABLE_LOCATIONS, 1)->isNull());
     $this->assertEquals(array(1, 2, 3, 4, 5), $sakuraIds);
     $this->assertEquals(array(1, 2, 3, 4, 5), $roseIds);
     $this->assertTrue(DataMapperFacade::find(static::TABLE_SAKURAS, array('id' => $sakuraIds))->isNull());
     $this->assertTrue(DataMapperFacade::find(static::TABLE_ROSES, array('id' => $roseIds))->isNull());
 }
 /**
  * testDeleteSetNull
  *
  * @return  void
  *
  * @covers  \Windwalker\Relation\Handler\OneToManyRelation::delete
  */
 public function testDeleteSetNull()
 {
     $location = $this->createTestTable(null, Action::SET_NULL);
     $location->load(3);
     $sakuraIds = $location->sakuras->id;
     $roseIds = $location->roses->id;
     $location->delete();
     $this->assertTrue(DataMapperFacade::findOne(static::TABLE_LOCATIONS, 3)->isNull());
     $this->assertEquals(array(11, 12, 13, 14, 15), $sakuraIds);
     $this->assertEquals(array(11, 12, 13, 14, 15), $roseIds);
     $sakuras = DataMapperFacade::find(static::TABLE_SAKURAS, array('id' => $sakuraIds));
     $roses = DataMapperFacade::find(static::TABLE_ROSES, array('id' => $roseIds));
     $this->assertEquals(array(11, 12, 13, 14, 15), $sakuras->id);
     $this->assertEquals(array(11, 12, 13, 14, 15), $roses->id);
     $this->assertEquals(array(0, 0, 0, 0, 0), $sakuras->location);
     $this->assertEquals(array(0, 0, 0, 0, 0), $roses->location);
 }
 /**
  * testDeleteSetNull
  *
  * @return  void
  *
  * @covers  \Windwalker\Relation\Handler\OneToManyRelation::delete
  */
 public function testDeleteSetNull()
 {
     $sakura = $this->createTestTable(null, Action::SET_NULL);
     $sakura->load(12);
     $this->assertEquals(array(25, 15, 8, 16, 24), DataMapperFacade::find(static::TABLE_SAKURA_ROSE_MAPS, array('sakura_id' => 12))->rose_id);
     $sakura->delete();
     $this->assertTrue(DataMapperFacade::findOne(static::TABLE_SAKURAS, 12)->isNull());
     $this->assertEquals(array(), DataMapperFacade::find(static::TABLE_SAKURA_ROSE_MAPS, array('sakura_id' => 12))->rose_id);
     $this->assertTrue(DataMapperFacade::find(static::TABLE_ROSES, array('id' => array(25, 15, 8, 16, 24)))->notNull());
 }