public function setUp() { $jobCollection = new JobCollection(); $job = new Job(); $job->setTitle('Job 1'); $jobCollection->add($job); $job = new Job(); $job->setTitle('Job 2'); $jobCollection->add($job); $this->iterator = new Iterator($jobCollection); }
/** * @param array $filters * * @return JobCollection * @throws Exception\CareerjetException */ public function search(array $filters = []) : JobCollection { $collection = new JobCollection(); $search = ['affid' => $this->affiliateId]; if (isset($filters['keywords'])) { // empty allowed $search['keywords'] = $filters['keywords']; } if (isset($filters['location'])) { // empty allowed $search['location'] = $filters['location']; } if (isset($filters['limit'])) { // max 99 $search['pagesize'] = $filters['limit']; } $search['page'] = isset($filters['offset']) ? $filters['offset'] : 1; // starts on 1 $result = $this->api->search($search); foreach ($result->jobs as $job) { $collection->add(JobBuilder::fromApi($job, $this->country)); } return $collection; }
public function testAddShouldThrowInvalidArgumentExceptionWhenAddingInvalidObjectToArrayData() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Object is not an instance of ' . Job::class); $this->collection->add(new \stdClass()); }