コード例 #1
0
ファイル: JobTest.php プロジェクト: jobbrander/jobs-common
 public function testItCanBeRepresentedAsArray()
 {
     $attributes = $this->getJobAttributes();
     $address = new PostalAddress();
     $hiringOrg = new Organization();
     $jobLocation = new Place();
     $geoCoordinates = new GeoCoordinates();
     $hiringOrg->setAddress($address);
     $jobLocation->setAddress($address);
     $job = new Job($attributes);
     $jobArray = $job->setHiringOrganization($hiringOrg)->setJobLocation($jobLocation)->toArray();
     array_walk_recursive($attributes, function ($value, $key) use($jobArray) {
         $this->assertEquals($jobArray[$key], $value);
     });
     $this->assertEquals($hiringOrg->toArray(), $jobArray['hiringOrganization']);
     $this->assertEquals($address->toArray(), $jobArray['hiringOrganization']['address']);
     $this->assertEquals($jobLocation->toArray(), $jobArray['jobLocation']);
     $this->assertEquals($address->toArray(), $jobArray['jobLocation']['address']);
 }
コード例 #2
0
ファイル: Job.php プロジェクト: jobbrander/jobs-common
 /**
  * Gets address from location if it exists or creates if it doesn't
  *
  * @param Place $location
  *
  * @return PostalAddress
  */
 private function getOrCreatePostalAddress(Place $location)
 {
     $address = $location->getAddress();
     if (!$address) {
         $address = new PostalAddress();
     }
     return $address;
 }