protected function createQuestionnaire()
 {
     $person = new Person();
     $person->getAddress()->setPostcode('11AA 2BB');
     $questionnaire = (new Questionnaire($person))->setCompletedDate(new \DateTime());
     return $questionnaire;
 }
 protected function mockQuestionnaireService()
 {
     $qs = \Mockery::mock('TransformCore\\PHE\\HayApi\\PersistenceBundle\\Service\\QuestionnaireService')->shouldIgnoreMissing();
     $person = new Person();
     $person->getAddress()->setPostcode('11AA 2BB');
     $questionnaire = new Questionnaire($person);
     $qs->shouldReceive('getQuestionnairesForExpiry')->withAnyArgs()->andReturn(array($questionnaire, $questionnaire, $questionnaire, $questionnaire));
     return $qs;
 }
 public function testExtractAddress()
 {
     $expectedKeys = array('postCode');
     $person = new Person();
     $export = RespondentHelper::extractAddress($person->getAddress());
     foreach ($expectedKeys as $key) {
         $this->assertArrayHasKey($key, $export);
     }
 }
 /**
  * @param Person   $person
  * @param Drinking $drinking
  * @return bool
  */
 protected static function unitsInLowRiskForGender(Person $person, Drinking $drinking)
 {
     $units = DrinkingScore::getWeeklyUnits($drinking);
     switch ($person->getGender()) {
         case Person::GENDER_FEMALE:
             return $units < DrinkingScore::RAG_RED_FEMALE_CUTOFF && $units > DrinkingScore::RAG_GREEN_CUTOFF;
         case Person::GENDER_MALE:
             return $units < DrinkingScore::RAG_RED_MALE_CUTOFF && $units > DrinkingScore::RAG_GREEN_CUTOFF;
     }
 }
 /**
  * @inheritdoc
  */
 protected function generateFemaleOption()
 {
     $person = new Person();
     $person->setGender(Person::GENDER_FEMALE)->setFirstName('Patti')->setLastName('Cline')->setAge(65);
     $questionnaire = new Questionnaire($person);
     $questionnaire->setDateCreated($this->creationDate)->getAboutYou()->getFeelings()->setEnergy(100)->setWeight(60)->setMood(75)->setFatigue(10)->setFitness(10)->setStress(25)->setCompletedDate($this->creationDate);
     $questionnaire->getAboutYou()->getHindrances()->setNotRelevant(true)->setCompletedDate($this->creationDate);
     $questionnaire->getAboutYou()->getMotivations()->setAppearance(true)->setCompletedDate($this->creationDate);
     $questionnaire->getAboutYou()->getDependants()->setGrandChildren(true)->setCompletedDate($this->creationDate);
     return $questionnaire;
 }
 public function testIGetAmberIfIDrinkUnder6DaysAWeekWithABingeAndIAmMale()
 {
     $person = new Person();
     $person->setGender(Person::GENDER_MALE);
     $questionnaire = new Questionnaire($person);
     $questionnaire->getAboutYou()->getFeelings()->setFatigue(40);
     $drinking = $questionnaire->getDrinking();
     $drinking->setDoYouDrink(Drinking::DOES_DRINK)->setWhichDaysDoYouDrink('wed, thurs, sat')->setWeekendDrinks((new Drinks())->setBeerCiderBottleAmount(3)->setSpiritsAmount(3))->setWeekdayDrinks((new Drinks())->setBeerCiderBottleAmount(1))->setCompletedDate(new \DateTime());
     $questionnaire->setDrinking($drinking);
     $expected = array('drinking' => array('drinking_amber_low_fatigue_lte_14_units_has_binge'));
     $this->assertEquals($expected, $this->instance->buildNarrative($questionnaire)->getMessages());
 }
 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());
 }
 /**
  * @return Questionnaire
  */
 public function getQuestionnaire()
 {
     if (!self::$questionnaire instanceof Questionnaire) {
         $person = new Person();
         $person->setFirstName('Test Person')->setAge(55)->setGender('male');
         $questionnaire = new Questionnaire($person);
         $this->getEntityManager()->persist($questionnaire);
         $this->getEntityManager()->flush($questionnaire);
         self::$questionnaire = $questionnaire;
     } else {
         self::$questionnaire = $this->getEntityManager()->getRepository(get_class(self::$questionnaire))->findOneBy(array('id' => self::$questionnaire->getId()));
     }
     return self::$questionnaire;
 }
 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()->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 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());
 }
 protected function createTestSet()
 {
     $person1 = new Person();
     $person1->setGender('male')->getAddress()->setCounty('AA')->setDistrict('A1')->setPostcode('AAAAA');
     $person2 = new Person();
     $person2->setGender('female')->getAddress()->setCounty($person1->getAddress()->getCounty())->setDistrict('A2')->setPostcode('AAABBB');
     $person3 = new Person();
     $person3->setGender('')->getAddress()->setCounty($person2->getAddress()->getCounty())->setDistrict($person2->getAddress()->getDistrict())->setPostcode('AAAAABB');
     $q1 = (new Questionnaire($person1))->setCompletedDate(new \DateTime())->setHashed(true);
     $q2 = (new Questionnaire($person2))->setCompletedDate(new \DateTime())->setHashed(true);
     $q3 = (new Questionnaire($person3))->setCompletedDate(new \DateTime())->setHashed(true);
     $this->getEntityManager()->persist($q1);
     $this->getEntityManager()->flush($q1);
     $this->getEntityManager()->persist($q2);
     $this->getEntityManager()->flush($q2);
     $this->getEntityManager()->persist($q3);
     $this->getEntityManager()->flush($q3);
 }
 /**
  * Questionnaire constructor.
  * @param Person $person
  */
 public function __construct(Person $person)
 {
     $this->person = $person;
     $this->dateCreated = new \DateTime();
     $this->aboutYou = new AboutYou($this);
     $this->drinking = new Drinking($this);
     $this->smoking = new Smoking($this);
     $this->eating = new Eating($this);
     $this->moving = new Moving($this);
     $this->person->setQuestionnaire($this);
 }
 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));
 }
 /**
  * @param Person $person
  * @return Person
  */
 protected function obfuscatePerson(Person $person)
 {
     $person->setFirstName($this->hashValue($person->getFirstName()))->setLastName($this->hashValue($person->getLastName()))->setEmailAddress($this->hashValue($person->getEmailAddress()))->getAddress()->setPostcode($this->hashValue($person->getAddress()->getPostcode()));
     return $person;
 }
 /**
  * @param Person $person
  * @return array
  */
 public static function extractRespondent(Person $person)
 {
     return array("title" => $person->getTitle(), "firstName" => $person->getFirstName(), "lastName" => $person->getLastName(), "age" => $person->getAge(), "gender" => $person->getGender(), "emailAddress" => $person->getEmailAddress(), "hasOptedIn" => true === $person->isSignedUp() ? "true" : "false");
 }
 public function testGetPreferredDrinkTypeForAFemale()
 {
     $person = new Person();
     $person->setGender(Person::GENDER_FEMALE);
     $questionnaire = new Questionnaire($person);
     $drinking = $questionnaire->getDrinking();
     $drinking->setWeekdayDrinks((new Drinks())->setBeerCiderPintAmount(1))->setWeekendDrinks(new Drinks());
     $expected = array('type' => Drinking::DRINK_TYPE_PINT, 'count' => 2);
     $this->assertEquals($expected, $drinking->getPreferredDrinkType());
 }
 /**
  * @param Person $person
  * @return Questionnaire
  * @throws \Doctrine\ORM\NonUniqueResultException
  */
 public function getQuestionnaireFromPerson(Person $person)
 {
     $query = $this->getEntityManager()->createQueryBuilder()->select('q')->from("TransformCore\\PHE\\HayApi\\PersistenceBundle\\Entity\\Questionnaire", "q")->where("q.id = :person_questionnaire_id")->setParameter("person_questionnaire_id", $person->getQuestionnaire()->getId())->getQuery();
     return $query->getOneOrNullResult();
 }
 public function testGetFavouriteDrinkTypeWhenDuplicated()
 {
     $person = new Person();
     $person->setGender(Person::GENDER_MALE);
     $questionnaire = new Questionnaire($person);
     $drinking = $questionnaire->getDrinking();
     $drinking->setDoYouDrink(Drinking::DOES_DRINK)->setWhichDaysDoYouDrink('sat, sun')->setWeekendDrinks((new Drinks())->setBeerCiderPintAmount(3)->setWineAmount(3))->setCompletedDate(new \DateTime());
     $this->assertEquals(Drinking::DRINK_TYPE_PINT, DrinkingScore::calculatePreferredDrinkType($drinking));
 }
Exemplo n.º 21
0
 public function testGetSetSignedUp()
 {
     $this->assertFalse($this->instance->isSignedUp());
     $this->assertInstanceOf(Person::class, $this->instance->setSignedUp(true));
     $this->assertTrue($this->instance->isSignedUp());
 }