コード例 #1
0
 function testSaveRootLevel()
 {
     $make = new VF_Level('make');
     $make->setTitle(self::ENTITY_TITLE);
     $make = $this->saveAndReload($make);
     $this->assertNotEquals(0, $make->getId(), 'saved entity should have an id value');
     $this->assertSame(self::ENTITY_TITLE, $make->getTitle(), 'saved entity should have correct title value');
 }
コード例 #2
0
ファイル: UpdaterTest.php プロジェクト: vehiclefits/library
 function testSaveRootLevel()
 {
     $make = new VF_Level('make');
     $make->setTitle('Honda');
     $make = $this->saveAndReload($make);
     $make->setTitle('Acura');
     $make = $this->saveAndReload($make);
     $this->assertSame('Acura', $make->getTitle(), 'saved entity should have correct title value');
 }
コード例 #3
0
 function testConformsLevelMake()
 {
     return $this->markTestIncomplete();
     $honda = new VF_Level('make');
     $honda->setTitle('Honda');
     $honda->save();
     $honda2 = new VF_Level('make');
     $honda2->setTitle('Honda');
     $honda2->save();
     $this->assertEquals($honda->getId(), $honda2->getId(), 'when saving two makes with same title, they should get the same id');
 }
コード例 #4
0
 function testUsesOneQueryOnMultipleCalls()
 {
     $level = new VF_Level('make');
     $level->setTitle('make');
     $id = $level->save();
     $this->getReadAdapter()->getProfiler()->clear();
     $this->getReadAdapter()->getProfiler()->setEnabled(true);
     $level = new VF_Level('make', $id);
     $level = new VF_Level('make', $id);
     $queries = $this->getReadAdapter()->getProfiler()->getQueryProfiles();
     $this->assertEquals(1, count($queries));
 }
コード例 #5
0
ファイル: MMYTest.php プロジェクト: vehiclefits/library
 function testDoesntConformModelFromDiffrentMake()
 {
     $honda = new VF_Level('make');
     $honda->setTitle('Honda');
     $honda_make_id = $honda->save();
     $civic = new VF_Level('model');
     $civic->setTitle('Civic');
     $civic->save($honda_make_id);
     $ford = new VF_Level('make');
     $ford->setTitle('Ford');
     $ford_make_id = $ford->save();
     $civic2 = new VF_Level('model');
     $civic2->setTitle('Civic');
     $civic2->save($ford_make_id);
     $this->assertEquals($civic->getId(), $civic2->getId(), 'when saving two models with same title, but under different makes, they should get same ids');
 }
コード例 #6
0
ファイル: Vehicle.php プロジェクト: vehiclefits/library
 function getLevel($level)
 {
     if ($this->hasLoadedLevel($level)) {
         return $this->levels[$level];
     }
     if ($this->levelIsOutsideFlexibleSelection($level)) {
         return new VF_Level($level, 0, $this->schema());
     }
     $id = $this->getValue($level);
     $levelFinder = new VF_Level_Finder($this->schema());
     $object = $levelFinder->find($level, $id);
     if (false == $object) {
         $object = new VF_Level($level, $id, $this->schema());
         if (false == $id) {
             $title = isset($this->titles[$level]) ? $this->titles[$level] : '';
             $object->setTitle($title);
         }
     }
     $this->levels[$level] = $object;
     return $object;
 }
コード例 #7
0
 function newLevel($level, $title)
 {
     $level = new VF_Level($level);
     $level->setTitle($title);
     return $level;
 }
コード例 #8
0
ファイル: Selector.php プロジェクト: vehiclefits/library
 /** @return VF_Level */
 function findEntityByTitle($type, $title, $parent_id = 0)
 {
     $levelId = $this->findEntityIdByTitle($type, $title, $parent_id);
     if (!$levelId) {
         return false;
     }
     $level = new VF_Level($type, $levelId, $this->getSchema());
     $level->setTitle($title);
     return $level;
 }
コード例 #9
0
 function saveAction()
 {
     $id = (int) $this->getRequest()->getParam('save');
     $entity = new VF_Level($this->getEntity()->getType(), $id);
     $entity->setTitle($this->getRequest()->getParam('title'));
     $entity->save($this->requestLevels());
     if ($this->getRequest()->isXmlHttpRequest()) {
         echo $entity->getId();
         exit;
     }
     $this->doSave();
 }