/** * @covers YAYOG\Workout::addExercise * @covers YAYOG\Workout::getType */ public function testAddExerciseSetsType() { $exercise1 = new Exercise(); $exercise1->setType('Stappers 8 reps'); $this->workout->addExercise($exercise1); $this->assertEquals('Stappers', $this->workout->getType()); }
/** * Parses one workout with the exercises. The rest exercises will be omitted, only actual * exercises are created. * * @param string $content Log file content for one workout * @throws InvalidArgumentException If the string could not be converted to a workout object * @return Workout The workout object with the exercises */ protected function getWorkout($content) { $lines = explode("\n\n", $content); $parts = str_getcsv(array_shift($lines)); if (count($parts) != 4 || !count($lines)) { throw new InvalidArgumentException('Could not convert string to a workout object'); } $workout = new Workout(); $workout->setDate(new DateTime($parts[0] . ', ' . $parts[1]))->setProgram(substr($parts[2], 0, -8))->setDay(substr($parts[3], 4)); foreach ($lines as $line) { $exercise = $this->getExercise($line); if ($exercise->getType() != 'Rest') { $workout->addExercise($exercise); } } return $workout; }
/** * @covers YAYOG\History::addWorkout */ public function testAddWorkoutAddsExercises() { $workout = new Workout(); $exercises = array(new Exercise(), new Exercise(), new Exercise()); foreach ($exercises as $exercise) { $workout->addExercise($exercise); } $history = $this->getMock('YAYOG\\History', array('addExercises')); $history->expects($this->once())->method('addExercises')->with($exercises); $history->addWorkout($workout); }