@@ -865,6 +865,84 @@ public function shouldAddVariable()
865
865
$ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , $ expectedKey , $ expectedValue ));
866
866
}
867
867
868
+ /**
869
+ * @test
870
+ */
871
+ public function shouldAddVariableWithProtected ()
872
+ {
873
+ $ expectedKey = 'ftp_port ' ;
874
+ $ expectedValue = '21 ' ;
875
+ $ expectedProtection = true ;
876
+
877
+ $ expectedArray = array (
878
+ 'key ' => $ expectedKey ,
879
+ 'value ' => $ expectedValue ,
880
+ 'protected ' => true ,
881
+ );
882
+
883
+ $ api = $ this ->getApiMock ();
884
+ $ api ->expects ($ this ->once ())
885
+ ->method ('post ' )
886
+ ->with ('projects/1/variables ' , $ expectedArray )
887
+ ->will ($ this ->returnValue ($ expectedArray ))
888
+ ;
889
+
890
+ $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , $ expectedKey , $ expectedValue , $ expectedProtection ));
891
+ }
892
+
893
+ /**
894
+ * @test
895
+ */
896
+ public function shouldAddVariableWithEnvironment ()
897
+ {
898
+ $ expectedKey = 'ftp_port ' ;
899
+ $ expectedValue = '21 ' ;
900
+ $ expectedProtection = null ;
901
+ $ expectedEnvironment = 'production ' ;
902
+
903
+ $ expectedArray = array (
904
+ 'key ' => $ expectedKey ,
905
+ 'value ' => $ expectedValue ,
906
+ 'environment_scope ' => $ expectedEnvironment ,
907
+ );
908
+
909
+ $ api = $ this ->getApiMock ();
910
+ $ api ->expects ($ this ->once ())
911
+ ->method ('post ' )
912
+ ->with ('projects/1/variables ' , $ expectedArray )
913
+ ->will ($ this ->returnValue ($ expectedArray ))
914
+ ;
915
+
916
+ $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , $ expectedKey , $ expectedValue , $ expectedProtection , $ expectedEnvironment ));
917
+ }
918
+
919
+ /**
920
+ * @test
921
+ */
922
+ public function shouldAddVariableWithProtectionAndEnvironment ()
923
+ {
924
+ $ expectedKey = 'ftp_port ' ;
925
+ $ expectedValue = '21 ' ;
926
+ $ expectedProtection = true ;
927
+ $ expectedEnvironment = 'production ' ;
928
+
929
+ $ expectedArray = array (
930
+ 'key ' => $ expectedKey ,
931
+ 'value ' => $ expectedValue ,
932
+ 'protected ' => true ,
933
+ 'environment_scope ' => $ expectedEnvironment ,
934
+ );
935
+
936
+ $ api = $ this ->getApiMock ();
937
+ $ api ->expects ($ this ->once ())
938
+ ->method ('post ' )
939
+ ->with ('projects/1/variables ' , $ expectedArray )
940
+ ->will ($ this ->returnValue ($ expectedArray ))
941
+ ;
942
+
943
+ $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , $ expectedKey , $ expectedValue , $ expectedProtection , $ expectedEnvironment ));
944
+ }
945
+
868
946
/**
869
947
* @test
870
948
*/
0 commit comments