function testSaveIsRepeatable()
 {
     $vehicle = $this->createVehicle(array('make' => 'Honda', 'model' => 'Civic', 'year' => 2000));
     $model = new VF_Level('model');
     $model->setTitle('Civic');
     $model->save($vehicle->getValue('make'));
     $this->assertEquals($vehicle->getValue('model'), $model->getId(), 'saving multiple times should keep the same id');
 }
Esempio n. 2
0
 function testSaveLevelWithParent()
 {
     $model = new VF_Level('model');
     $model->setTitle('Civic');
     $model->save();
     $model = $this->findEntityById($model->getId(), $model->getType());
     $model->setTitle('Accord');
     $model->save();
     $model = $this->findEntityById($model->getId(), $model->getType());
     $this->assertSame('Accord', $model->getTitle(), 'saved entity should have correct title value');
 }
Esempio n. 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');
 }
 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));
 }
Esempio n. 5
0
 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');
 }
Esempio n. 6
0
 protected function insertLevel($level, $title = '', $parent_id = 0, $config = null)
 {
     $id = $this->findEntityIdByTitle($title, $level);
     if ($id) {
         return $id;
     }
     $entity = new VF_Level($level);
     if (!is_null($config)) {
         $entity->setConfig($config);
     }
     $entity->setTitle($title);
     $id = $entity->save($parent_id);
     return $id;
 }
 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();
 }