示例#1
0
 public function testElevationCalculation()
 {
     $R = new Object(array(Object::ELEVATIONS_CORRECTED => array(100, 120, 110)));
     $I = new Inserter($this->PDO, $R);
     $I->setAccountID(0);
     $I->insert();
     $data = $this->PDO->query('SELECT * FROM `' . PREFIX . 'route` WHERE `accountid`=0')->fetch(PDO::FETCH_ASSOC);
     $N = new Object($data);
     $this->assertGreaterThan(0, $N->elevation());
     $this->assertGreaterThan(0, $N->elevationUp());
     $this->assertGreaterThan(0, $N->elevationDown());
 }
示例#2
0
 public function testSimpleUpdate()
 {
     $Inserter = new Inserter($this->PDO);
     $Inserter->setAccountID(0);
     $Inserter->insert(new Object(array(Object::NAME => 'Route name', Object::DISTANCE => 3.14)));
     $Route = new Object($this->PDO->query('SELECT * FROM `' . PREFIX . 'route` WHERE `id`=' . $Inserter->insertedID())->fetch(PDO::FETCH_ASSOC));
     $Route->set(Object::DISTANCE, 0);
     $Changed = clone $Route;
     $Changed->set(Object::NAME, 'New route name');
     $Updater = new Updater($this->PDO, $Changed, $Route);
     $Updater->setAccountID(0);
     $Updater->update();
     $Result = new Object($this->PDO->query('SELECT * FROM `' . PREFIX . 'route` WHERE `id`=' . $Inserter->insertedID())->fetch(PDO::FETCH_ASSOC));
     $this->assertEquals('New route name', $Result->name());
     $this->assertEquals(3.14, $Result->distance());
 }