/** * Test getEvents() method */ public function testGetEvents() { $event1 = JobApplicationEvent::getJobApplicationEvent(1); $event2 = JobApplicationEvent::getJobApplicationEvent(2); $event3 = JobApplicationEvent::getJobApplicationEvent(3); // Invalid app id try { $events = JobApplicationEvent::getEvents('12A'); } catch (JobApplicationEventException $e) { $this->assertEquals(JobApplicationEventException::INVALID_PARAMETER, $e->getCode()); } // app id with no events $events = JobApplicationEvent::getEvents(3); $this->assertTrue(is_array($events)); $this->assertEquals(0, count($events)); // app id with events $events = JobApplicationEvent::getEvents(1); $this->assertTrue(is_array($events)); $this->assertEquals(2, count($events)); $expected = array($event1, $event2); $this->_compareEventsWithOrder($expected, $events); $events = JobApplicationEvent::getEvents(2); $expected = array($event3); $this->assertTrue(is_array($events)); $this->assertEquals(1, count($events)); $this->_compareEventsWithOrder($expected, $events); }
public function getEvents() { if (!isset($this->events) && isset($this->id)) { // Get application events $events = JobApplicationEvent::getEvents($this->id); $this->events = $events; } return $this->events; }