@@ -135,6 +135,73 @@ public function shouldRemoveSchedule(): void
135135 $ this ->assertEquals ($ expectedBool , $ api ->remove (1 , 2 ));
136136 }
137137
138+ /**
139+ * @test
140+ */
141+ public function shouldCreateScheduleVariable (): void
142+ {
143+ $ expectedArray = [
144+ 'key ' => 'FOO_BAR ' ,
145+ 'variable_type ' => 'env_var ' ,
146+ 'value ' => 'BAZ ' ,
147+ ];
148+
149+ $ api = $ this ->getApiMock ();
150+ $ api ->expects ($ this ->once ())
151+ ->method ('post ' )
152+ ->with ('projects/1/pipeline_schedules/2/variables ' , $ expectedArray )
153+ ->will ($ this ->returnValue ($ expectedArray ));
154+
155+ $ this ->assertEquals ($ expectedArray , $ api ->addVariable (
156+ 1 ,
157+ 2 ,
158+ $ expectedArray
159+ ));
160+ }
161+
162+ /**
163+ * @test
164+ */
165+ public function shouldUpdateScheduleVariable (): void
166+ {
167+ $ variabelName = 'FOO_BAR ' ;
168+ $ expectedArray = [
169+ 'key ' => $ variabelName ,
170+ 'variable_type ' => 'env_var ' ,
171+ 'value ' => 'BAZ ' ,
172+ ];
173+
174+ $ api = $ this ->getApiMock ();
175+ $ api ->expects ($ this ->once ())
176+ ->method ('put ' )
177+ ->with ('projects/1/pipeline_schedules/2/variables/ ' . $ variabelName , $ expectedArray )
178+ ->will ($ this ->returnValue ($ expectedArray ));
179+
180+ $ this ->assertEquals ($ expectedArray , $ api ->updateVariable (
181+ 1 ,
182+ 2 ,
183+ $ variabelName ,
184+ $ expectedArray
185+ ));
186+ }
187+
188+ /**
189+ * @test
190+ */
191+ public function shouldRemoveScheduleVariable (): void
192+ {
193+ $ expectedBool = true ;
194+
195+ $ api = $ this ->getApiMock ();
196+ $ api ->expects ($ this ->once ())
197+ ->method ('delete ' )
198+ ->with ('projects/1/pipeline_schedules/2/variables/FOO_BAR ' )
199+ ->will ($ this ->returnValue ($ expectedBool ))
200+ ;
201+
202+ $ this ->assertEquals ($ expectedBool , $ api ->removeVariable (1 , 2 , 'FOO_BAR ' ));
203+ }
204+
138205 protected function getApiClass ()
139206 {
140207 return Schedules::class;
0 commit comments