@@ -865,6 +865,70 @@ 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
+ $ expectedArray = array (
874
+ 'key ' => 'DEPLOY_SERVER ' ,
875
+ 'value ' => 'stage.example.com ' ,
876
+ 'protected ' => true ,
877
+ );
878
+
879
+ $ api = $ this ->getApiMock ();
880
+ $ api ->expects ($ this ->once ())
881
+ ->method ('post ' )
882
+ ->with ('projects/1/variables ' , $ expectedArray )
883
+ ->will ($ this ->returnValue ($ expectedArray ))
884
+ ;
885
+
886
+ $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , 'DEPLOY_SERVER ' , 'stage.example.com ' , true ));
887
+ }
888
+
889
+ /**
890
+ * @test
891
+ */
892
+ public function shouldAddVariableWithEnvironment ()
893
+ {
894
+ $ expectedArray = array (
895
+ 'key ' => 'DEPLOY_SERVER ' ,
896
+ 'value ' => 'stage.example.com ' ,
897
+ 'environment_scope ' => 'staging ' ,
898
+ );
899
+
900
+ $ api = $ this ->getApiMock ();
901
+ $ api ->expects ($ this ->once ())
902
+ ->method ('post ' )
903
+ ->with ('projects/1/variables ' , $ expectedArray )
904
+ ->will ($ this ->returnValue ($ expectedArray ))
905
+ ;
906
+
907
+ $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , 'DEPLOY_SERVER ' , 'stage.example.com ' , null , 'staging ' ));
908
+ }
909
+
910
+ /**
911
+ * @test
912
+ */
913
+ public function shouldAddVariableWithProtectionAndEnvironment ()
914
+ {
915
+ $ expectedArray = array (
916
+ 'key ' => 'DEPLOY_SERVER ' ,
917
+ 'value ' => 'stage.example.com ' ,
918
+ 'protected ' => true ,
919
+ 'environment_scope ' => 'staging ' ,
920
+ );
921
+
922
+ $ api = $ this ->getApiMock ();
923
+ $ api ->expects ($ this ->once ())
924
+ ->method ('post ' )
925
+ ->with ('projects/1/variables ' , $ expectedArray )
926
+ ->will ($ this ->returnValue ($ expectedArray ))
927
+ ;
928
+
929
+ $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , 'DEPLOY_SERVER ' , 'stage.example.com ' , true , 'staging ' ));
930
+ }
931
+
868
932
/**
869
933
* @test
870
934
*/
@@ -888,6 +952,70 @@ public function shouldUpdateVariable()
888
952
$ this ->assertEquals ($ expectedArray , $ api ->updateVariable (1 , $ expectedKey , $ expectedValue ));
889
953
}
890
954
955
+ /**
956
+ * @test
957
+ */
958
+ public function shouldUpdateVariableWithProtected ()
959
+ {
960
+ $ expectedArray = array (
961
+ 'key ' => 'DEPLOY_SERVER ' ,
962
+ 'value ' => 'stage.example.com ' ,
963
+ 'protected ' => true ,
964
+ );
965
+
966
+ $ api = $ this ->getApiMock ();
967
+ $ api ->expects ($ this ->once ())
968
+ ->method ('put ' )
969
+ ->with ('projects/1/variables/DEPLOY_SERVER ' , array ('value ' => 'stage.example.com ' , 'protected ' => true ))
970
+ ->will ($ this ->returnValue ($ expectedArray ))
971
+ ;
972
+
973
+ $ this ->assertEquals ($ expectedArray , $ api ->updateVariable (1 , 'DEPLOY_SERVER ' , 'stage.example.com ' , true ));
974
+ }
975
+
976
+ /**
977
+ * @test
978
+ */
979
+ public function shouldUpdateVariableWithEnvironment ()
980
+ {
981
+ $ expectedArray = array (
982
+ 'key ' => 'DEPLOY_SERVER ' ,
983
+ 'value ' => 'stage.example.com ' ,
984
+ 'environment_scope ' => 'staging ' ,
985
+ );
986
+
987
+ $ api = $ this ->getApiMock ();
988
+ $ api ->expects ($ this ->once ())
989
+ ->method ('put ' )
990
+ ->with ('projects/1/variables/DEPLOY_SERVER ' , array ('value ' => 'stage.example.com ' , 'environment_scope ' => 'staging ' ))
991
+ ->will ($ this ->returnValue ($ expectedArray ))
992
+ ;
993
+
994
+ $ this ->assertEquals ($ expectedArray , $ api ->updateVariable (1 , 'DEPLOY_SERVER ' , 'stage.example.com ' , null , 'staging ' ));
995
+ }
996
+
997
+ /**
998
+ * @test
999
+ */
1000
+ public function shouldUpdateVariableWithProtectedAndEnvironment ()
1001
+ {
1002
+ $ expectedArray = array (
1003
+ 'key ' => 'DEPLOY_SERVER ' ,
1004
+ 'value ' => 'stage.example.com ' ,
1005
+ 'protected ' => true ,
1006
+ 'environment_scope ' => 'staging ' ,
1007
+ );
1008
+
1009
+ $ api = $ this ->getApiMock ();
1010
+ $ api ->expects ($ this ->once ())
1011
+ ->method ('put ' )
1012
+ ->with ('projects/1/variables/DEPLOY_SERVER ' , array ('value ' => 'stage.example.com ' , 'protected ' => true , 'environment_scope ' => 'staging ' ))
1013
+ ->will ($ this ->returnValue ($ expectedArray ))
1014
+ ;
1015
+
1016
+ $ this ->assertEquals ($ expectedArray , $ api ->updateVariable (1 , 'DEPLOY_SERVER ' , 'stage.example.com ' , true , 'staging ' ));
1017
+ }
1018
+
891
1019
/**
892
1020
* @test
893
1021
*/
0 commit comments