@@ -870,13 +870,9 @@ public function shouldAddVariable()
870
870
*/
871
871
public function shouldAddVariableWithProtected ()
872
872
{
873
- $ expectedKey = 'ftp_port ' ;
874
- $ expectedValue = '21 ' ;
875
- $ expectedProtection = true ;
876
-
877
873
$ expectedArray = array (
878
- 'key ' => $ expectedKey ,
879
- 'value ' => $ expectedValue ,
874
+ 'key ' => ' DEPLOY_SERVER ' ,
875
+ 'value ' => ' stage.example.com ' ,
880
876
'protected ' => true ,
881
877
);
882
878
@@ -887,23 +883,18 @@ public function shouldAddVariableWithProtected()
887
883
->will ($ this ->returnValue ($ expectedArray ))
888
884
;
889
885
890
- $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , $ expectedKey , $ expectedValue , $ expectedProtection ));
886
+ $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , ' DEPLOY_SERVER ' , ' stage.example.com ' , true ));
891
887
}
892
888
893
889
/**
894
890
* @test
895
891
*/
896
892
public function shouldAddVariableWithEnvironment ()
897
893
{
898
- $ expectedKey = 'ftp_port ' ;
899
- $ expectedValue = '21 ' ;
900
- $ expectedProtection = null ;
901
- $ expectedEnvironment = 'production ' ;
902
-
903
894
$ expectedArray = array (
904
- 'key ' => $ expectedKey ,
905
- 'value ' => $ expectedValue ,
906
- 'environment_scope ' => $ expectedEnvironment ,
895
+ 'key ' => ' DEPLOY_SERVER ' ,
896
+ 'value ' => ' stage.example.com ' ,
897
+ 'environment_scope ' => ' staging ' ,
907
898
);
908
899
909
900
$ api = $ this ->getApiMock ();
@@ -913,24 +904,19 @@ public function shouldAddVariableWithEnvironment()
913
904
->will ($ this ->returnValue ($ expectedArray ))
914
905
;
915
906
916
- $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , $ expectedKey , $ expectedValue , $ expectedProtection , $ expectedEnvironment ));
907
+ $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , ' DEPLOY_SERVER ' , ' stage.example.com ' , null , ' staging ' ));
917
908
}
918
909
919
910
/**
920
911
* @test
921
912
*/
922
913
public function shouldAddVariableWithProtectionAndEnvironment ()
923
914
{
924
- $ expectedKey = 'ftp_port ' ;
925
- $ expectedValue = '21 ' ;
926
- $ expectedProtection = true ;
927
- $ expectedEnvironment = 'production ' ;
928
-
929
915
$ expectedArray = array (
930
- 'key ' => $ expectedKey ,
931
- 'value ' => $ expectedValue ,
916
+ 'key ' => ' DEPLOY_SERVER ' ,
917
+ 'value ' => ' stage.example.com ' ,
932
918
'protected ' => true ,
933
- 'environment_scope ' => $ expectedEnvironment ,
919
+ 'environment_scope ' => ' staging ' ,
934
920
);
935
921
936
922
$ api = $ this ->getApiMock ();
@@ -940,7 +926,7 @@ public function shouldAddVariableWithProtectionAndEnvironment()
940
926
->will ($ this ->returnValue ($ expectedArray ))
941
927
;
942
928
943
- $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , $ expectedKey , $ expectedValue , $ expectedProtection , $ expectedEnvironment ));
929
+ $ this ->assertEquals ($ expectedArray , $ api ->addVariable (1 , ' DEPLOY_SERVER ' , ' stage.example.com ' , true , ' staging ' ));
944
930
}
945
931
946
932
/**
@@ -966,6 +952,70 @@ public function shouldUpdateVariable()
966
952
$ this ->assertEquals ($ expectedArray , $ api ->updateVariable (1 , $ expectedKey , $ expectedValue ));
967
953
}
968
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
+
969
1019
/**
970
1020
* @test
971
1021
*/
0 commit comments