public function testVerySimple() { $XML = simplexml_load_string_utf8(' <exercise> <created>2011-05-13 17:36:19.0</created> <time>2011-05-11 07:09:34.0</time> <sport>Cycling</sport> <name>Cycling</name> <result> <distance>17100.0</distance> <calories>500</calories> <duration>00:39:32</duration> <heart-rate> <average>146</average> <maximum>166</maximum> </heart-rate> </result> <note/> </exercise>'); $Parser = new ParserXMLpolarSingle('', $XML); $Parser->parse(); $this->assertFalse($Parser->failed()); $this->assertEquals(mktime(7, 9, 34, 5, 11, 2011), $Parser->object()->getTimestamp()); $this->assertEquals(17.1, $Parser->object()->getDistance()); $this->assertEquals(500, $Parser->object()->getCalories()); $this->assertEquals(39 * 60 + 32, $Parser->object()->getTimeInSeconds()); $this->assertEquals(146, $Parser->object()->getPulseAvg()); $this->assertEquals(166, $Parser->object()->getPulseMax()); }
/** * Parse single exercise * @param SimpleXMLElement $Exercise */ protected function parseSingleExercise(SimpleXMLElement &$Exercise) { $Parser = new ParserXMLpolarSingle('', $Exercise); $Parser->parse(); if ($Parser->failed()) { $this->addErrors($Parser->getErrors()); } else { $this->addObject($Parser->object()); } }