$g->setKilometersTo(12423); $g->setUserId($ut->getUserId('ruf')); $g->link('Vehicles', array($ut->getVehicleId('vw-touran-1-4-tsi'))); $g->link('Categories', array($ut->getIdForCategory('Tax'))); $g->save(); $sha1 = $g->getHash(); $t->isa_ok($sha1, 'string', '->save() creates a sha for each chart'); $g->setKilometersFrom(235); $g->save(); $sha2 = $g->getHash(); $t->cmp_ok($sha1, '!=', $sha2, '->save() The hash field is updated each time the object is changed'); $g = new Chart(); $g->setFormat('png'); $g->setKilometersTo(12423); $g->setUserId($ut->getUserId('ruf')); $g->link('Vehicles', array($ut->getVehicleId('vw-touran-1-4-tsi'))); $g->link('Categories', array($ut->getIdForCategory('Fuel'))); $sha = $g->getHash(); $g2 = new Chart(); $g2->setUserId($ut->getUserId('ruf')); $g->save(); $finalsha = $g->getHash(); $t->isnt($sha, $finalsha, 'When saving the object, ->save() checks that a unique sha is set. If not, a new one is generated.'); // ->delete() $t->diag('->delete()'); $g = new Chart(); $g->setUserId($ut->getUserId('ruf')); $g->save(); $id = $g->getId(); $path = $g->getChartFileSystemPath(); $fs = new sfFilesystem(new sfEventDispatcher());
protected function saveNewChart() { $chart = new Chart(); $params = $this->parameters; $foreign = array('categories_list' => 'Categories', 'vehicles_list' => 'Vehicles'); $chart->fromArray($this->parameters); foreach ($foreign as $field => $class) { if (isset($params[$field])) { $chart->link($class, $params[$field]); } } try { $chart->save(); } catch (Exception $exc) { $sfe = new sfException(); throw $sfe->createFromException($exc); } $this->chart = $chart; return $chart; }