16
16
use Jobs \Entity \Job ;
17
17
use Jobs \Entity \JsonLdProviderInterface ;
18
18
use Jobs \Entity \Location ;
19
+ use Jobs \Entity \Salary ;
19
20
use Organizations \Entity \Organization ;
20
21
use Organizations \Entity \OrganizationName ;
21
22
@@ -43,13 +44,16 @@ class JsonLdProviderTest extends \PHPUnit_Framework_TestCase
43
44
'@testInheritance ' => ['as_reflection ' => true ],
44
45
'@testConstructSetsJob ' => false ,
45
46
'@testGeneratesJsonLdWithoutOrganizationAndDate ' => [
46
- 'args ' => 'getJobWoOrgAndDate '
47
+ 'args ' => 'getJobWoOrgAndDate ' ,
47
48
],
49
+ '@testGeneratesJsonLdWithSalary ' => [
50
+ 'args ' => 'getJobWithSalary ' ,
51
+ ]
48
52
];
49
53
50
54
private $ inheritance = [ JsonLdProviderInterface::class ];
51
55
52
- private function getJob ($ withOrganization =true , $ withDatePublishStart =true )
56
+ private function getJob ($ withOrganization =true , $ withDatePublishStart =true , $ withSalary = false )
53
57
{
54
58
$ job = new Job ();
55
59
$ organization = new Organization ();
@@ -67,6 +71,10 @@ private function getJob($withOrganization=true, $withDatePublishStart=true)
67
71
$ locations ->add ($ location );
68
72
$ job ->setLocations ($ locations );
69
73
74
+ if ($ withSalary ) {
75
+ $ job ->getSalary ()->setValue (1000 )->setCurrency ('EUR ' )->setUnit (Salary::UNIT_DAY );
76
+ }
77
+
70
78
return [$ job ];
71
79
}
72
80
@@ -75,6 +83,11 @@ private function getJobWoOrgAndDate()
75
83
return $ this ->getJob (false , false );
76
84
}
77
85
86
+ private function getJobWithSalary ()
87
+ {
88
+ return $ this ->getJob (false , false , true );
89
+ }
90
+
78
91
public function testConstructSetsJob ()
79
92
{
80
93
$ job = new Job ();
@@ -102,4 +115,34 @@ public function testGeneratesJsonLdWithoutOrganizationAndDate()
102
115
103
116
$ this ->assertNull ($ array ['datePosted ' ]);
104
117
}
118
+
119
+ public function testGeneratesJsonLdWithoutSalary ()
120
+ {
121
+ $ json = $ this ->target ->toJsonLd ();
122
+
123
+ $ array = json_decode ($ json , JSON_OBJECT_AS_ARRAY );
124
+
125
+ $ this ->assertArrayNotHasKey ('baseSalary ' , $ array );
126
+ }
127
+
128
+ public function testGeneratesJsonLdWithSalary ()
129
+ {
130
+ $ json = $ this ->target ->toJsonLd ();
131
+
132
+ $ array = json_decode ($ json , JSON_OBJECT_AS_ARRAY );
133
+
134
+ $ this ->assertArrayHasKey ('baseSalary ' , $ array );
135
+
136
+ $ expect = [
137
+ '@type ' => 'MonetaryAmount ' ,
138
+ 'currency ' => 'EUR ' ,
139
+ 'value ' => [
140
+ '@type ' => 'QuantitiveValue ' ,
141
+ 'value ' => 1000 ,
142
+ 'unitText ' => Salary::UNIT_DAY ,
143
+ ],
144
+ ];
145
+
146
+ $ this ->assertEquals ($ expect , $ array ['baseSalary ' ]);
147
+ }
105
148
}
0 commit comments