コード例 #1
0
ファイル: InserterTest.php プロジェクト: n0rthface/Runalyze
 public function testSimpleInsert()
 {
     $Type = new Object(array(Object::NAME => 'Type name', Object::ABBREVIATION => 'Tn', Object::SPORTID => 1, Object::HR_AVG => 120, Object::QUALITY_SESSION => 1));
     $Inserter = new Inserter($this->PDO, $Type);
     $Inserter->setAccountID(1);
     $Inserter->insert();
     $data = $this->PDO->query('SELECT * FROM `' . PREFIX . 'type` WHERE `accountid`=1')->fetch(PDO::FETCH_ASSOC);
     $New = new Object($data);
     $this->assertEquals('Type name', $New->name());
     $this->assertEquals('Tn', $New->abbreviation());
     $this->assertEquals(1, $New->sportid());
     $this->assertEquals(120, $New->hrAvg());
     $this->assertEquals(true, $New->isQualitySession());
 }
コード例 #2
0
ファイル: UpdaterTest.php プロジェクト: n0rthface/Runalyze
 public function testSimpleUpdate()
 {
     $Inserter = new Inserter($this->PDO);
     $Inserter->setAccountID(1);
     $Inserter->insert(new Object(array(Object::NAME => 'Type name', Object::ABBREVIATION => 'Tn', Object::HR_AVG => 120, Object::QUALITY_SESSION => 1)));
     $Type = new Object($this->PDO->query('SELECT * FROM `' . PREFIX . 'type` WHERE `id`=' . $Inserter->insertedID())->fetch(PDO::FETCH_ASSOC));
     $Type->set(Object::ABBREVIATION, '');
     $Changed = clone $Type;
     $Changed->set(Object::NAME, 'New type name');
     $Updater = new Updater($this->PDO, $Changed, $Type);
     $Updater->setAccountID(1);
     $Updater->update();
     $Result = new Object($this->PDO->query('SELECT * FROM `' . PREFIX . 'type` WHERE `id`=' . $Inserter->insertedID())->fetch(PDO::FETCH_ASSOC));
     $this->assertEquals('New type name', $Result->name());
     $this->assertEquals('Tn', $Result->abbreviation());
     $this->assertEquals(120, $Result->hrAvg());
     $this->assertEquals(true, $Result->isQualitySession());
 }