@@ -254,7 +254,7 @@ public function shouldGetBuild()
254
254
255
255
$ this ->assertEquals ($ expectedArray , $ api ->build (1 , 2 ));
256
256
}
257
-
257
+
258
258
/**
259
259
* @test
260
260
*/
@@ -757,6 +757,106 @@ public function shouldRemoveService()
757
757
$ this ->assertEquals ($ expectedBool , $ api ->removeService (1 , 'hipchat ' ));
758
758
}
759
759
760
+ /**
761
+ * @test
762
+ */
763
+ public function shouldGetVariables ()
764
+ {
765
+ $ expectedArray = array (
766
+ array ('key ' => 'ftp_username ' , 'value ' => 'ftp ' ),
767
+ array ('key ' => 'ftp_password ' , 'value ' => 'somepassword ' )
768
+ );
769
+
770
+ $ api = $ this ->getApiMock ();
771
+ $ api ->expects ($ this ->once ())
772
+ ->method ('get ' )
773
+ ->with ('projects/1/variables ' )
774
+ ->will ($ this ->returnValue ($ expectedArray ))
775
+ ;
776
+
777
+ $ this ->assertEquals ($ expectedArray , $ api ->variables (1 ));
778
+ }
779
+
780
+ /**
781
+ * @test
782
+ */
783
+ public function shouldGetVariable ()
784
+ {
785
+ $ expectedArray = array ('key ' => 'ftp_username ' , 'value ' => 'ftp ' );
786
+
787
+ $ api = $ this ->getApiMock ();
788
+ $ api ->expects ($ this ->once ())
789
+ ->method ('get ' )
790
+ ->with ('projects/1/variables/ftp_username ' )
791
+ ->will ($ this ->returnValue ($ expectedArray ))
792
+ ;
793
+
794
+ $ this ->assertEquals ($ expectedArray , $ api ->variable (1 , 'ftp_username ' ));
795
+ }
796
+
797
+ /**
798
+ * @test
799
+ */
800
+ public function shouldAddVariable ()
801
+ {
802
+ $ expectedKey = 'ftp_port ' ;
803
+ $ expectedValue = '21 ' ;
804
+
805
+ $ expectedArray = array (
806
+ 'key ' => $ expectedKey ,
807
+ 'value ' => $ expectedValue ,
808
+ );
809
+
810
+ $ api = $ this ->getApiMock ();
811
+ $ api ->expects ($ this ->once ())
812
+ ->method ('post ' )
813
+ ->with ('projects/1/variables ' , $ expectedArray )
814
+ ->will ($ this ->returnValue ($ expectedArray ))
815
+ ;
816
+
817
+ $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , $ expectedKey , $ expectedValue ));
818
+ }
819
+
820
+ /**
821
+ * @test
822
+ */
823
+ public function shouldUpdateVariable ()
824
+ {
825
+ $ expectedKey = 'ftp_port ' ;
826
+ $ expectedValue = '22 ' ;
827
+
828
+ $ expectedArray = array (
829
+ 'key ' => 'ftp_port ' ,
830
+ 'value ' => '22 ' ,
831
+ );
832
+
833
+ $ api = $ this ->getApiMock ();
834
+ $ api ->expects ($ this ->once ())
835
+ ->method ('put ' )
836
+ ->with ('projects/1/variables/ ' .$ expectedKey , array ('value ' => $ expectedValue ))
837
+ ->will ($ this ->returnValue ($ expectedArray ))
838
+ ;
839
+
840
+ $ this ->assertEquals ($ expectedArray , $ api ->updateVariable (1 , $ expectedKey , $ expectedValue ));
841
+ }
842
+
843
+ /**
844
+ * @test
845
+ */
846
+ public function shouldRemoveVariable ()
847
+ {
848
+ $ expectedBool = true ;
849
+
850
+ $ api = $ this ->getApiMock ();
851
+ $ api ->expects ($ this ->once ())
852
+ ->method ('delete ' )
853
+ ->with ('projects/1/variables/ftp_password ' )
854
+ ->will ($ this ->returnValue ($ expectedBool ))
855
+ ;
856
+
857
+ $ this ->assertEquals ($ expectedBool , $ api ->removeVariable (1 , 'ftp_password ' ));
858
+ }
859
+
760
860
protected function getMultipleProjectsRequestMock ($ path , $ expectedArray = array (), $ page = 1 , $ per_page = 20 , $ order_by = 'created_at ' , $ sort = 'asc ' )
761
861
{
762
862
$ api = $ this ->getApiMock ();
0 commit comments