public function testGuidelines() { $data = array('MO' => array('1' => 11490, '2' => 15510, '3' => 19530, '4' => 23550, '5' => 27570, '6' => 31590, '7' => 35610, '8' => 39630, '9' => 43650, '10' => 47670), 'HI' => array('1' => 13230, '2' => 17850, '3' => 22470, '4' => 27090, '5' => 31710, '6' => 36330, '7' => 40950, '8' => 45570, '9' => 50190, '10' => 54810), 'AK' => array('1' => 14350, '2' => 19380, '3' => 24410, '4' => 29440, '5' => 34470, '6' => 39500, '7' => 44530, '8' => 49560, '9' => 54590, '10' => 59620)); $year = 2014; foreach ($data as $state => $table) { foreach ($table as $personsInHousehold => $householdIncome) { $object = FederalPovertyLevel::factory($state, $householdIncome, $personsInHousehold, $year); $povertyGuideline = $object->getPovertyGuideline(); $this->assertEquals($povertyGuideline, $householdIncome); } } }
/** * Factory * * @param string $state State Abbreviation * @param int $year Year * @param int $householdIncome Modified adjusted gross household income * @param int $personsInHousehold Number of persons in household * @return FederalPovertyLevel Populated object */ public static function factory($state, $householdIncome, $personsInHousehold, $year = null) { // If no year is defined, use the current if ($year === null) { $now = new DateTime(); $year = (int) $now->format("Y"); } $object = new FederalPovertyLevel(); $object->setState($state)->setYear($year)->setHouseholdIncome($householdIncome)->setPersonsInHousehold($personsInHousehold); return $object; }