public function testGetSetOccasionalDrinks()
 {
     $expected = (new Drinks())->setSpiritsAmount(1);
     $this->assertNotEquals($expected, $this->instance->getOccasionalDrinks());
     $this->assertInstanceOf(Drinking::class, $this->instance->setOccasionalDrinks($expected));
     $this->assertEquals($expected, $this->instance->getOccasionalDrinks());
 }
 /**
  * @param Drinking     $drinking
  * @param ParamFetcher $paramFetcher
  * @return Drinking
  * @throws \Exception
  */
 public function updateDrinking(Drinking $drinking, ParamFetcher $paramFetcher)
 {
     $entityManager = $this->getEntityManager();
     $drinking->setDoYouDrink($paramFetcher->get('do_you_drink'))->setWeekdayDrinks($this->createDrinks($paramFetcher, $drinking->getWeekdayDrinks(), Drinks::DRINKS_TYPE_WEEKDAY))->setWeekendDrinks($this->createDrinks($paramFetcher, $drinking->getWeekendDrinks(), Drinks::DRINKS_TYPE_WEEKEND))->setOccasionalDrinks($this->createDrinks($paramFetcher, $drinking->getOccasionalDrinks(), Drinks::DRINKS_TYPE_OCCASIONAL))->setWhichDaysDoYouDrink($paramFetcher->get('which_days_do_you_drink'))->setCompletedDate(new \DateTime());
     $entityManager->persist($drinking);
     $entityManager->flush();
     return $this->getQuestionnaireFromDrinking($drinking);
 }
 /**
  * @param Drinking $drinking
  * @param string   $section
  * @return int
  */
 protected function calculateDrinkingUnits(Drinking $drinking, $section = 'week')
 {
     $units = 0;
     switch ($section) {
         case 'week':
             $drinks = $drinking->getWeekdayDrinks();
             break;
         case 'weekend':
             $drinks = $drinking->getWeekendDrinks();
             break;
         default:
             $drinks = $drinking->getOccasionalDrinks();
             break;
     }
     $units += $drinks->getBeerCiderPintAmount() * self::DRINK_UNITS_PINT;
     $units += $drinks->getBeerCiderBottleAmount() * self::DRINK_UNITS_PINT;
     $units += $drinks->getWineAmount() * self::DRINK_UNITS_WINE;
     $units += $drinks->getSpiritsAmount() * self::DRINK_UNITS_SPIRIT;
     return $units;
 }
 /**
  * @param Drinking $drinking
  * @return array
  */
 public static function extractDrinking(Drinking $drinking)
 {
     return array_merge(array("drinkingDoYouDrink" => $drinking->getDoYouDrink(), "drinkingFrequency" => $drinking->getWhichDaysDoYouDrink()), self::extractDrinksForExport($drinking->getWeekdayDrinks()), self::extractDrinksForExport($drinking->getWeekendDrinks(), 'weekend'), self::extractDrinksForExport($drinking->getOccasionalDrinks(), 'occasional'), array("hasBinged" => $drinking->getBingingFrequency(), "drinkingCompleted" => $drinking->isCompleted(), "drinkingRag" => $drinking->getRagScore()['rag']));
 }