public function testGetSetGender() { $expected = "M"; $this->assertEmpty($this->instance->getGender()); $this->assertTrue($this->instance->setGender($expected) instanceof Person); $this->assertEquals($expected, $this->instance->getGender()); }
/** * @param Person $person * @param ParamFetcher $paramFetcher * @return Questionnaire * @throws \Exception */ public function updatePerson(Person $person, ParamFetcher $paramFetcher) { $entityManager = $this->getEntityManager(); $person->setTitle($paramFetcher->get('title'))->setFirstName($paramFetcher->get('firstname'))->setLastName($paramFetcher->get('lastname'))->setEmailAddress($paramFetcher->get('emailaddress'))->setSignedUp($paramFetcher->get("opt_in"))->setAddress($person->getAddress()->setAddressLines($paramFetcher->get('address'))->setPostcode($paramFetcher->get('postcode'))); $person->setAge(null === $paramFetcher->get('age') ? $person->getAge() : $paramFetcher->get('age')); $person->setGender(null === $paramFetcher->get('gender') ? $person->getGender() : $paramFetcher->get('gender')); $entityManager->persist($person); $entityManager->flush(); return $this->getQuestionnaireFromPerson($person); }
/** * @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(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('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('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()); }
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); }
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)); }
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()); }
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)); }