예제 #1
0
 public function testSimpleInsert()
 {
     $Object = new Object(array(Object::NAME => 'Sport name', Object::SHORT => 0, Object::CALORIES_PER_HOUR => 700, Object::HR_AVG => 140, Object::HAS_DISTANCES => 1, Object::PACE_UNIT => 'foo', Object::HAS_TYPES => 1, Object::HAS_POWER => 0, Object::IS_OUTSIDE => 1));
     $Inserter = new Inserter($this->PDO, $Object);
     $Inserter->setAccountID(1);
     $Inserter->insert();
     $data = $this->PDO->query('SELECT * FROM `' . PREFIX . 'sport` WHERE `accountid`=1')->fetch(PDO::FETCH_ASSOC);
     $Sport = new Object($data);
     $this->assertEquals('Sport name', $Sport->name());
     $this->assertEquals(700, $Sport->caloriesPerHour());
     $this->assertEquals(140, $Sport->avgHR());
     $this->assertEquals('foo', $Sport->paceUnit());
     $this->assertTrue($Sport->hasDistances());
     $this->assertTrue($Sport->hasTypes());
     $this->assertTrue($Sport->isOutside());
     $this->assertFalse($Sport->usesShortDisplay());
     $this->assertFalse($Sport->hasPower());
 }
    /**
     * Display the table with general records
     */
    private function displayRekorde()
    {
        foreach ($this->rekorde as $rekord) {
            echo '<table class="fullwidth zebra-style">';
            echo '<thead><tr><th colspan="11" class="l">' . $rekord['name'] . '</th></tr></thead>';
            echo '<tbody>';
            $output = false;
            $sports = DB::getInstance()->query($rekord['sportquery'])->fetchAll();
            $Request = DB::getInstance()->prepare($rekord['datquery']);
            foreach ($sports as $sportData) {
                $Request->bindValue('sportid', $sportData['id']);
                $Request->execute();
                $data = $Request->fetchAll();
                if (!empty($data)) {
                    $Sport = new Sport\Object($sportData);
                    $output = true;
                    echo '<tr class="r">';
                    echo '<td class="b l">' . $Sport->icon()->code() . ' ' . $Sport->name() . '</td>';
                    $j = 0;
                    foreach ($data as $j => $dat) {
                        if ($rekord['speed']) {
                            $Pace = new Pace($dat['s'], $dat['distance']);
                            $Pace->setUnit($Sport->paceUnit());
                            $code = $Pace->valueWithAppendix();
                        } else {
                            $code = $dat['distance'] != 0 ? Distance::format($dat['distance']) : Duration::format($dat['s']);
                        }
                        echo '<td class="small"><span title="' . date("d.m.Y", $dat['time']) . '">
								' . Ajax::trainingLink($dat['id'], $code) . '
							</span></td>';
                    }
                    for (; $j < 9; $j++) {
                        echo HTML::emptyTD();
                    }
                    echo '</tr>';
                }
            }
            if (!$output) {
                echo '<tr><td colspan="11"><em>' . __('No data available') . '</em></td></tr>';
            }
            echo '</tbody>';
            echo '</table>';
        }
    }