Ejemplo n.º 1
0
 /**
  * Parse the log file from the YAYOG app and return workout objects.
  *
  * @param string $content Content of the log file
  * @return History
  */
 public function parseTextFile($content)
 {
     $lines = array_reverse(array_filter(explode("\n\n<end>\n\n", $content)));
     $history = new History();
     foreach ($lines as $line) {
         $history->addWorkout($this->getWorkout($line));
     }
     return $history;
 }
Ejemplo n.º 2
0
 /**
  * @covers YAYOG\HtmlFormatter::renderHistory
  */
 public function testRenderHistory()
 {
     $formatter = $this->getMock('YAYOG\\HtmlFormatter', array('renderRelativeDate', 'renderType', 'renderExercises'));
     $history = new History();
     for ($i = 0; $i < 4; $i++) {
         $workout = new Workout();
         $workout->setDate(new DateTime());
         $history->addWorkout($workout);
     }
     $formatter->expects($this->exactly(4))->method('renderRelativeDate');
     $formatter->expects($this->exactly(4))->method('renderType');
     $formatter->expects($this->exactly(4))->method('renderExercises');
     $this->assertTag(array('tag' => 'div', 'children' => array('count' => 4, 'only' => array('tag' => 'h3'))), $formatter->renderHistory($history));
 }
Ejemplo n.º 3
0
 /**
  * @covers YAYOG\History::addWorkout
  */
 public function testAddWorkoutSetsPreviousWorkout()
 {
     $workout1 = new Workout();
     $workout1->setProgram('Basic')->setDay(4);
     $workout2 = new Workout();
     $workout2->setProgram('Basic')->setDay(4);
     $workout3 = new Workout();
     $workout3->setProgram('Basic')->setDay(6);
     $workouts = array($workout1, $workout2, $workout3);
     foreach ($workouts as $workout) {
         $this->history->addWorkout($workout);
     }
     $this->assertNull($workout1->getPreviousWorkout());
     $this->assertNull($workout3->getPreviousWorkout());
     $this->assertSame($workout1, $workout2->getPreviousWorkout());
 }