Ejemplo n.º 1
0
 /**
  * @param array $data
  * @return int
  */
 protected function insert(array $data)
 {
     $Inserter = new Inserter($this->PDO, new Object($data));
     $Inserter->setAccountID(0);
     $Inserter->insert();
     return $Inserter->insertedID();
 }
Ejemplo n.º 2
0
 /**
  * @param array $data
  * @param array $route
  * @param array $trackdata
  * @return int
  */
 protected function insertActivity(array $data, array $route, array $trackdata)
 {
     $Inserter = new Inserter($this->PDO, new Object($data));
     $Inserter->setRoute(new Route\Object($route));
     $Inserter->setTrackdata(new Trackdata\Object($trackdata));
     return $this->runInserter($Inserter);
 }
Ejemplo n.º 3
0
 public function testPowerCalculation()
 {
     // TODO: Needs configuration setting
     if (Configuration::ActivityForm()->computePower()) {
         $ActivityIndoor = new Object(array(Object::DISTANCE => 10, Object::TIME_IN_SECONDS => 3000, Object::SPORTID => $this->IndoorID));
         $Trackdata = new Model\Trackdata\Object(array(Model\Trackdata\Object::TIME => array(1500, 3000), Model\Trackdata\Object::DISTANCE => array(5, 10)));
         $Inserter = new Inserter($this->PDO);
         $Inserter->setAccountID(0);
         $Inserter->setTrackdata($Trackdata);
         $Inserter->insert($ActivityIndoor);
         $this->assertEquals(0, $this->fetch($Inserter->insertedID())->power());
         $ActivityOutdoor = clone $ActivityIndoor;
         $ActivityOutdoor->set(Object::SPORTID, $this->OutdoorID);
         $Inserter->insert($ActivityOutdoor);
         $this->assertNotEquals(0, $this->fetch($Inserter->insertedID())->power());
         $this->assertNotEmpty($Trackdata->power());
     }
 }
Ejemplo n.º 4
0
 public function testEquipment()
 {
     $this->PDO->exec('UPDATE `runalyze_equipment` SET `distance`=0, `time`=0 WHERE `id`=' . $this->EquipmentA);
     $this->PDO->exec('UPDATE `runalyze_equipment` SET `distance`=0, `time`=0 WHERE `id`=' . $this->EquipmentB);
     $Object = new Object(array(Object::DISTANCE => 10, Object::TIME_IN_SECONDS => 3600, Object::SPORTID => 1));
     $Inserter = new Inserter($this->PDO);
     $Inserter->setAccountID(0);
     $Inserter->setEquipmentIDs(array($this->EquipmentA));
     $Inserter->insert($Object);
     $this->assertEquals(array(10, 3600), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentA)->fetch(PDO::FETCH_NUM));
     $this->assertEquals(array(0, 0), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentB)->fetch(PDO::FETCH_NUM));
     $Deleter = new Deleter($this->PDO, $Object);
     $Deleter->setAccountID(0);
     $Deleter->setEquipmentIDs(array($this->EquipmentA));
     $Deleter->delete();
     $this->assertEquals(array(0, 0), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentA)->fetch(PDO::FETCH_NUM));
     $this->assertEquals(array(0, 0), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentB)->fetch(PDO::FETCH_NUM));
 }
Ejemplo n.º 5
0
 public function testEquipment()
 {
     $this->PDO->exec('UPDATE `runalyze_equipment` SET `distance`=0, `time`=0 WHERE `id`=' . $this->EquipmentA);
     $this->PDO->exec('UPDATE `runalyze_equipment` SET `distance`=0, `time`=0 WHERE `id`=' . $this->EquipmentB);
     $OldObject = new Object(array(Object::DISTANCE => 12.34, Object::TIME_IN_SECONDS => 3600, Object::SPORTID => $this->OutdoorID));
     $Inserter = new Inserter($this->PDO);
     $Inserter->setAccountID(0);
     $Inserter->setEquipmentIDs(array($this->EquipmentA));
     $Inserter->insert($OldObject);
     $this->assertEquals(array(12.34, 3600), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentA)->fetch(PDO::FETCH_NUM));
     $this->assertEquals(array(0.0, 0), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentB)->fetch(PDO::FETCH_NUM));
     $NewObject = clone $OldObject;
     $Updater = new Updater($this->PDO, $NewObject, $OldObject);
     $Updater->setAccountID(0);
     $Updater->setEquipmentIDs(array($this->EquipmentB), array($this->EquipmentA));
     $Updater->update();
     $this->assertEquals(array(0.0, 0), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentA)->fetch(PDO::FETCH_NUM));
     $this->assertEquals(array(12.34, 3600), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentB)->fetch(PDO::FETCH_NUM));
 }