/**
  * @group AppKit
  */
 public function testSwapKeys()
 {
     $test = array('test1' => 'OK', 'test2' => 'OK', 'test3' => 'OK');
     $test2 = $test;
     $rewrite = array('test2' => 'LAOLA2');
     AppKitArrayUtil::swapKeys($test, $rewrite, true);
     AppKitArrayUtil::swapKeys($test2, $rewrite, false);
     $this->assertCount(1, $test);
     $this->assertArrayHasKey('LAOLA2', $test);
     $this->assertArrayNotHasKey('test3', $test);
     $this->assertArrayNotHasKey('test1', $test);
     $this->assertCount(3, $test2);
     $this->assertArrayHasKey('LAOLA2', $test2);
     $this->assertArrayHasKey('test3', $test2);
 }
 /**
  * Create of update a category
  * @param array $cat
  * @return Ambigous <NULL, CronkCategory>
  */
 public function createCategory(array $cat)
 {
     AppKitArrayUtil::swapKeys($cat, self::$cat_map, true);
     $category = null;
     if ($this->agaviUser->hasCredential('icinga.cronk.category.admin') && isset($cat['cc_uid'])) {
         $category = AppKitDoctrineUtil::createQuery()->from('CronkCategory cc')->andWhere('cc.cc_uid=?', $cat['cc_uid'])->execute()->getFirst();
     }
     if (!$category instanceof CronkCategory || !$category->cc_id > 0) {
         $category = new CronkCategory();
     }
     $category->fromArray($cat);
     $category->save();
     return $category;
 }