/** * @covers PDOforRunalyze::fetchByID * @covers PDOforRunalyze::deleteByID */ public function testFetchByID() { $this->assertEquals(0, $this->object->query('SELECT COUNT(*) FROM `runalyze_training`')->fetchColumn()); $this->object->exec('INSERT INTO `runalyze_training` (`id`, `s`, `accountid`) VALUES(1, 100, 0)'); $this->object->exec('INSERT INTO `runalyze_training` (`id`, `s`, `accountid`) VALUES(2, 200, 0)'); $this->object->exec('INSERT INTO `runalyze_training` (`id`, `s`, `accountid`) VALUES(3, 300, 0)'); $Training1 = $this->object->fetchByID('training', 1); $this->assertEquals(100, $Training1['s']); $Training2 = $this->object->fetchByID('training', 2); $this->assertEquals(200, $Training2['s']); $Training3 = $this->object->fetchByID('training', 3); $this->assertEquals(300, $Training3['s']); $this->assertEquals(3, $this->object->query('SELECT COUNT(*) FROM `runalyze_training`')->fetchColumn()); $this->object->deleteByID('training', 2); $this->assertEquals("1,3", $this->object->query('SELECT GROUP_CONCAT(`id`) FROM `runalyze_training` GROUP BY `accountid`')->fetchColumn()); $this->assertEquals(2, $this->object->query('SELECT COUNT(*) FROM `runalyze_training`')->fetchColumn()); $this->object->deleteByID('training', 1); $this->object->deleteByID('training', 3); $this->assertEquals(0, $this->object->query('SELECT COUNT(*) FROM `runalyze_training`')->fetchColumn()); $this->object->exec('TRUNCATE TABLE `runalyze_training`'); }