public function setUp()
 {
     $this->builder = new NarrativeBuilder();
     $person = new Person();
     $person->setGender('male')->setAge('40')->setFirstName(uniqid('FN_'));
     $this->questionnaire = new Questionnaire($person);
     $this->questionnaire->getAboutYou()->setCompletedDate(new \DateTime());
     $this->questionnaire->getAboutYou()->getFeelings()->setEnergy(100)->setFatigue(100)->setMood(100)->setFitness(100)->setStress(100)->setWeight(35)->setCompletedDate(new \DateTime());
     $this->questionnaire->getEating()->setDrinksChoice('water')->setBreakfastChoice('other')->setCheeseChoice('other')->setProteinChoice('5')->setFruitAndVegChoice('5')->setPotatoesChoice('other')->setDailySnackChoice('')->setCompletedDate(new \DateTime());
     $this->questionnaire->getSmoking()->setDoYouSmoke('no')->setCompletedDate(new \DateTime());
     $this->questionnaire->getDrinking()->setDoYouDrink(Drinking::DRINK_TWO_TO_FOUR_TIMES_A_MONTH)->setBingingFrequency(Drinking::BINGE_L_T_MONTHLY)->setCompletedDate(new \DateTime());
     $moving = array('mon' => 30, 'wed' => 30, 'fri' => 30, 'sun' => 30);
     $this->questionnaire->getMoving()->setAerobicActivityDays($moving)->setStrengtheningActivityDays($moving)->setCompletedDate(new \DateTime());
 }
 public function setUp()
 {
     $this->builder = new NarrativeBuilder();
     $person = new Person();
     $person->setGender('male')->setAge('40')->setFirstName(uniqid('FN_'));
     $this->questionnaire = new Questionnaire($person);
     $this->questionnaire->getAboutYou()->setCompletedDate(new \DateTime());
     $this->questionnaire->getAboutYou()->getFeelings()->setEnergy(100)->setFatigue(100)->setMood(100)->setFitness(100)->setStress(100)->setWeight(80)->setCompletedDate(new \DateTime());
     $this->questionnaire->getEating()->setDrinksChoice('water')->setBreakfastChoice('other')->setCheeseChoice('other')->setProteinChoice('5')->setFruitAndVegChoice('5')->setPotatoesChoice('other')->setDailySnackChoice('')->setCompletedDate(new \DateTime());
     $this->questionnaire->getSmoking()->setDoYouSmoke('yes')->setCompletedDate(new \DateTime());
     $this->questionnaire->getDrinking()->setDoYouDrink(Drinking::DO_NOT_DRINK)->setWhichDaysDoYouDrink('mon, tue, wed, thur, fri, sat, sun')->setCompletedDate(new \DateTime());
     $moving = array('mon' => 30, 'tue' => 30, 'wed' => 30, 'thur' => 30, 'fri' => 30, 'sat' => 30, 'sun' => 30);
     $this->questionnaire->getMoving()->setAerobicActivityDays($moving)->setStrengtheningActivityDays($moving)->setCompletedDate(new \DateTime());
 }
 public function setUp()
 {
     $this->builder = new NarrativeBuilder();
     $person = new Person();
     $person->setGender('female')->setAge('40')->setFirstName(uniqid('FN_'));
     $this->questionnaire = new Questionnaire($person);
     $this->questionnaire->getAboutYou()->setCompletedDate(new \DateTime());
     $this->questionnaire->getAboutYou()->getFeelings()->setEnergy(100)->setFatigue(100)->setMood(100)->setFitness(100)->setStress(100)->setWeight(35)->setCompletedDate(new \DateTime());
     $this->questionnaire->getEating()->setDrinksChoice('sugary drink')->setBreakfastChoice('sugary cereal')->setCheeseChoice('hard cheese')->setProteinChoice('ham')->setFruitAndVegChoice('0')->setPotatoesChoice('chips')->setDailySnackChoice('sweets, crisps, cake, biscuits')->setCompletedDate(new \DateTime());
     $this->questionnaire->getSmoking()->setDoYouSmoke('no')->setCompletedDate(new \DateTime());
     $drinks = (new Drinks())->setBeerCiderPintAmount(5)->setBeerCiderBottleAmount(5);
     $this->questionnaire->getDrinking()->setDoYouDrink(Drinking::DOES_DRINK)->setWhichDaysDoYouDrink('thur, fri, sat')->setWeekendDrinks($drinks)->setWeekdayDrinks($drinks)->setCompletedDate(new \DateTime());
     $moving = array('mon' => 40, 'tue' => 40, 'wed' => 40, 'sun' => 40);
     $this->questionnaire->getMoving()->setAerobicActivityDays($moving)->setStrengtheningActivityDays($moving)->setCompletedDate(new \DateTime());
 }
 public function setUp()
 {
     $this->builder = new NarrativeBuilder();
     $person = new Person();
     $person->setGender('male')->setAge('40')->setFirstName(uniqid('FN_'));
     $this->questionnaire = new Questionnaire($person);
     $this->questionnaire->getAboutYou()->setCompletedDate(new \DateTime());
     $this->questionnaire->getAboutYou()->getFeelings()->setEnergy(30)->setFatigue(30)->setMood(30)->setFitness(30)->setStress(30)->setWeight(0)->setCompletedDate(new \DateTime());
     $this->questionnaire->getEating()->setDrinksChoice('water')->setBreakfastChoice('other')->setCheeseChoice('other')->setProteinChoice('5')->setFruitAndVegChoice('5')->setPotatoesChoice('other')->setDailySnackChoice('')->setCompletedDate(new \DateTime());
     $this->questionnaire->getSmoking()->setDoYouSmoke('no')->setCompletedDate(new \DateTime());
     $drinks = new Drinks();
     $drinks->setBeerCiderPintAmount(2);
     $this->questionnaire->getDrinking()->setDoYouDrink(Drinking::DOES_DRINK)->setWeekdayDrinks($drinks)->setWeekendDrinks($drinks)->setWhichDaysDoYouDrink('mon,  wed, fri, sun')->setCompletedDate(new \DateTime());
     $this->questionnaire->getMoving()->setCompletedDate(new \DateTime());
 }
 public function setUp()
 {
     $this->builder = new NarrativeBuilder();
     $person = new Person();
     $person->setGender('female')->setAge('40')->setFirstName(uniqid('FN_'));
     $this->questionnaire = new Questionnaire($person);
     $this->questionnaire->getAboutYou()->setCompletedDate(new \DateTime());
     $this->questionnaire->getAboutYou()->getFeelings()->setWeight(0)->setCompletedDate(new \DateTime());
     $this->questionnaire->getEating()->setDrinksChoice('sugary drink')->setBreakfastChoice('sugary cereals')->setCheeseChoice('hard cheese')->setProteinChoice('ham')->setFruitAndVegChoice('0')->setPotatoesChoice('chips')->setDailySnackChoice('cake, biscuits, crisps, sweets')->setCompletedDate(new \DateTime());
     $this->questionnaire->getSmoking()->setDoYouSmoke('yes')->setCompletedDate(new \DateTime());
     $drinks = new Drinks();
     $drinks->setBeerCiderPintAmount(5)->setWineAmount(3)->setSpiritsAmount(5)->setCompletedDate(new \DateTime());
     $this->questionnaire->getDrinking()->setDoYouDrink(Drinking::DOES_DRINK)->setWhichDaysDoYouDrink('mon, tue, wed, thur, fri, sat, sun')->setWeekendDrinks($drinks)->setWeekdayDrinks($drinks)->setCompletedDate(new \DateTime());
     $this->questionnaire->getMoving()->setCompletedDate(new \DateTime());
 }
 public function testSpecificationIsTrue()
 {
     $days = array('mon' => 30, 'tues' => 30, 'wed' => 30);
     $questionnaire = new Questionnaire(new Person());
     $questionnaire->getMoving()->setAerobicActivityDays($days);
     $this->assertTrue(AerobicTimeLT150MinsDaysGTE3Specification::isSatisfiedBy($questionnaire));
 }
 /**
  * @inheritdoc
  */
 public function calculateScore(Questionnaire $questionnaire)
 {
     if ($questionnaire->getMoving()->isCompleted()) {
         $this->extractMovingScore($questionnaire);
     }
     return $this->getRag();
 }
 public function testSpecificationIsTrue()
 {
     $days = array('mon' => 80, 'tues' => 80);
     $questionnaire = new Questionnaire(new Person());
     $questionnaire->getMoving()->setAerobicActivityDays($days);
     $this->assertTrue(AmberMovingAmberAerobicLowDaysRedStrengthSpecification::isSatisfiedBy($questionnaire));
 }
 public function testIGetARedMessageWithFitnessQuestionForMoving()
 {
     $questionnaire = new Questionnaire(new Person());
     $questionnaire->getMoving()->setCompletedDate(new \DateTime());
     $questionnaire->getAboutYou()->getFeelings()->setFitness(21);
     $expected = array('moving' => array('moving_red', 'moving_red_low_fitness'));
     $this->assertEquals($expected, $this->instance->buildNarrative($questionnaire)->getMessages());
 }
 public function testCompletedSectionsButNoQuestionnaireDate()
 {
     $this->instance->getDrinking()->setCompletedDate(new \DateTime());
     $this->instance->getEating()->setCompletedDate(new \DateTime());
     $this->instance->getMoving()->setCompletedDate(new \DateTime());
     $this->instance->getSmoking()->setCompletedDate(new \DateTime());
     $this->assertTrue($this->instance->isCompleted());
 }
 public function testIHaveLessThan60MinutesAndLessThanThreeDaysIAmAerobicRed()
 {
     $aerobic = array('mon' => 15, 'tue' => 15);
     $questionnaire = new Questionnaire(new Person());
     $moving = $questionnaire->getMoving();
     $moving->setAerobicActivityDays($aerobic)->setCompletedDate(new \DateTime());
     $questionnaire->setMoving($moving);
     $this->assertTrue(AerobicIsRedSpecification::isSatisfiedBy($questionnaire));
 }
 public function testIHave150MinutesAnd3OrMoreDaysIAmAerobicGreen()
 {
     $aerobic = array('mon' => 50, 'tue' => 50, 'wed' => 50);
     $questionnaire = new Questionnaire(new Person());
     $moving = $questionnaire->getMoving();
     $moving->setAerobicActivityDays($aerobic)->setCompletedDate(new \DateTime());
     $questionnaire->setMoving($moving);
     $this->assertTrue(AerobicIsGreenSpecification::isSatisfiedBy($questionnaire));
 }
 public function testExtractMoving()
 {
     $expectedKeys = array("movingAerobicActivityDuration", "movingAerobicActivityDays", "strengtheningActivityDays", "movingCompleted", "movingRag");
     $questionnaire = new Questionnaire(new Person());
     $export = MovingHelper::extractMoving($questionnaire->getMoving());
     foreach ($expectedKeys as $key) {
         $this->assertArrayHasKey($key, $export);
     }
 }
 public function testIHave60OrMoreMinutesAndLessThanTwoDaysIAmAerobicAmber()
 {
     $aerobic = array('mon' => 50, 'wed' => 40);
     $questionnaire = new Questionnaire(new Person());
     $moving = $questionnaire->getMoving();
     $moving->setAerobicActivityDays($aerobic)->setCompletedDate(new \DateTime());
     $questionnaire->setMoving($moving);
     $this->assertFalse(AerobicIsGreenSpecification::isSatisfiedBy($questionnaire));
     $this->assertFalse(AerobicIsRedSpecification::isSatisfiedBy($questionnaire));
 }
 /**
  * @param Questionnaire $questionnaire
  * @return int
  */
 protected function generateScore(Questionnaire $questionnaire)
 {
     $result = 0;
     $result += $questionnaire->getDrinking()->getRagScore()['value'];
     $result += $questionnaire->getMoving()->getRagScore()['value'];
     $result += $questionnaire->getEating()->getRagScore()['value'];
     $result += $questionnaire->getSmoking()->getRagScore()['value'];
     if ($questionnaire->getSmoking()->getRagScore()['rag'] === RagScore::RAG_RED) {
         if ($result > self::RED_CUTOFF) {
             return self::RED_CUTOFF;
         }
     }
     return $result;
 }
 public function testIGetANonEmptyResultsNarrativeOnACompleteQuiz()
 {
     $person = (new Person())->setFirstName('test')->setGender('female');
     $completedDate = new \DateTime();
     $questionnaire = new Questionnaire($person);
     $aboutYou = $questionnaire->getAboutYou();
     $aboutYou->getFeelings()->setCompletedDate($completedDate);
     $aboutYou->getHindrances()->setCompletedDate($completedDate);
     $aboutYou->getMotivations()->setCompletedDate($completedDate);
     $aboutYou->getDependants()->setCompletedDate($completedDate);
     $questionnaire->setAboutYou($aboutYou->setCompletedDate($completedDate));
     $questionnaire->getDrinking()->setCompletedDate($completedDate);
     $questionnaire->getEating()->setCompletedDate($completedDate);
     $questionnaire->getMoving()->setCompletedDate($completedDate);
     $questionnaire->getSmoking()->setCompletedDate($completedDate);
     $results = ResultsNarrativeHelper::extractResultsNarrative($questionnaire, $this->translator);
     foreach ($results as $result) {
         $this->assertEquals(base64_encode(self::TRANS_STRING), $result);
     }
 }
 /**
  * @inheritDoc
  */
 public static function isSatisfiedBy(Questionnaire $questionnaire)
 {
     return $questionnaire->getMoving()->getAerobicActivityDays() < self::AEROBIC_DAYS_EXCEED;
 }
 public function testIGetARedRagWhenISmoke()
 {
     $person = new Person();
     $person->setGender('female');
     $questionnaire = new Questionnaire($person);
     $drinking = $questionnaire->getDrinking();
     $drinking->setWeekendDrinks(new Drinks())->setWeekdayDrinks(new Drinks())->setCompletedDate(new \DateTime());
     $questionnaire->setDrinking($drinking);
     $questionnaire->getSmoking()->setCompletedDate(new \DateTime());
     $moving = $questionnaire->getMoving();
     $movingArray = array('mon' => 50, 'tue' => 50, 'wed' => 50);
     $moving->setAerobicActivityDays($movingArray)->setStrengtheningActivityDays($movingArray)->setCompletedDate(new \DateTime());
     $questionnaire->setMoving($moving);
     $questionnaire->getEating()->setCompletedDate(new \DateTime());
     $questionnaire->getSmoking()->setDoYouSmoke('yes')->setCompletedDate(new \DateTime());
     $expected = array('value' => QuestionnaireScore::SCORE_RED, 'rag' => QuestionnaireScore::RAG_RED, 'normalized_score' => QuestionnaireScore::RED_CUTOFF);
     $this->assertEquals($expected, $this->instance->calculateScore($questionnaire));
 }
 /**
  * @inheritDoc
  */
 public static function isSatisfiedBy(Questionnaire $questionnaire)
 {
     return $questionnaire->getMoving()->isCompleted();
 }
 /**
  * Cutoff is 3 days of 10+ minutes with a min total of 150 minutes for aerobic
  * 2 days of 30+ minutes for strength
  */
 public function testIGetGreenWithExactCutoffs()
 {
     $aerobic = array('mon' => 50, 'tue' => 50, 'wed' => 50);
     $strength = array('mon' => 30, 'tue' => 30);
     $questionnaire = new Questionnaire(new Person());
     $moving = $questionnaire->getMoving();
     $moving->setAerobicActivityDays($aerobic)->setStrengtheningActivityDays($strength)->setCompletedDate(new \DateTime());
     $questionnaire->setMoving($moving);
     $result = $this->instance->calculateScore($questionnaire);
     $this->assertEquals(MovingScore::SCORE_GREEN, $result['value']);
     $this->assertEquals(MovingScore::RAG_GREEN, $result['rag']);
 }
 /**
  * @inheritDoc
  */
 public static function isSatisfiedBy(Questionnaire $questionnaire)
 {
     return $questionnaire->getMoving()->getAerobicActivityDays() < MovingScore::AEROBIC_DAYS_GREEN && $questionnaire->getMoving()->getAerobicActivityDuration() >= MovingScore::AEROBIC_MINUTES_GREEN;
 }
 public function testSubstitutionOfThreeOrMoreMotivations()
 {
     $questionnaire = new Questionnaire(new Person());
     $questionnaire->getPerson()->setGender('male');
     $questionnaire->getMoving()->setCompletedDate(new \DateTime());
     $questionnaire->getEating()->setCompletedDate(new \DateTime());
     $questionnaire->getDrinking()->setCompletedDate(new \DateTime());
     $questionnaire->getSmoking()->setCompletedDate(new \DateTime());
     $questionnaire->getAboutYou()->getMotivations()->setAlertness(true)->setAppearance(true)->setWeight(true)->setEnergy(true);
     $priorityCopy = $this->instance->buildNarrative($questionnaire)->getSubstitutions()['{{PRIORITY_COPY}}'];
     $this->assertEquals(1, substr_count($priorityCopy, 'and'));
     $this->assertEquals(1, substr_count($priorityCopy, ', '));
 }
 public function testSpecificationReturnsTrue()
 {
     $questionnaire = new Questionnaire(new Person());
     $questionnaire->getMoving()->setCompletedDate(new \DateTime());
     $this->assertTrue($this->instance->isSatisfiedBy($questionnaire));
 }
 /**
  * @inheritDoc
  */
 public static function isSatisfiedBy(Questionnaire $questionnaire)
 {
     return $questionnaire->getMoving()->getAerobicActivityDuration() < MovingScore::AEROBIC_MINUTES_RED;
 }
 /**
  * @inheritDoc
  */
 public static function isSatisfiedBy(Questionnaire $questionnaire)
 {
     return $questionnaire->getMoving()->getRagScore()['rag'] === RagScore::RAG_AMBER;
 }
 /**
  * @inheritDoc
  */
 public static function isSatisfiedBy(Questionnaire $questionnaire)
 {
     return $questionnaire->getMoving()->getStrengtheningActivityDays() < MovingScore::STRENGTH_DAYS_GREEN;
 }