public function testGetValues() { $badge1 = new Badge("badge1"); $badge2 = new Badge("badge2"); $badges = array($badge1, $badge2); $values = Badge::getValues($badges); $this->assertIsA($values, "Array", "getValues() should return an array"); $this->assertEqual(2, count($values), "Array should contain 2 elements"); $this->assertIsA($values[0], "Array"); $this->assertIsA($values[1], "Array"); $this->assertEqual("badge1", $values[0]['name'], "Name should equal the input"); $this->assertEqual("badge2", $values[1]['name'], "Name should equal the input"); }
/** * Extracts the won badges of one kind from the response of the database. * * @param array $badgesData The database response for on kind of badges. * * @return array All won badges of one kind. */ protected function extractBadges(array $badgesData) { $badges = array(); foreach ($badgesData as $badgeData) { $badgeId = $badgeData['badge_id']; $createDate = $badgeData['create_date']; $badge = Badge::findById($badgeId); $badge->setCreateDate($createDate); $badges[] = $badge; } return $badges; }