@@ -1609,6 +1609,53 @@ public function shouldAddVariableWithProtectionAndEnvironment(): void
1609
1609
);
1610
1610
}
1611
1611
1612
+ /**
1613
+ * @test
1614
+ */
1615
+ public function shouldAddVariableWithEnvironmentAndVariableType (): void
1616
+ {
1617
+ $ expectedArray = [
1618
+ 'key ' => 'DEPLOY_SERVER ' ,
1619
+ 'value ' => 'stage.example.com ' ,
1620
+ 'environment_scope ' => 'staging ' ,
1621
+ 'variable_type ' => 'file ' ,
1622
+ ];
1623
+
1624
+ $ api = $ this ->getApiMock ();
1625
+ $ api ->expects ($ this ->once ())
1626
+ ->method ('post ' )
1627
+ ->with ('projects/1/variables ' , $ expectedArray )
1628
+ ->will ($ this ->returnValue ($ expectedArray ));
1629
+
1630
+ $ this ->assertEquals (
1631
+ $ expectedArray ,
1632
+ $ api ->addVariable (1 , 'DEPLOY_SERVER ' , 'stage.example.com ' , null , 'staging ' , ['variable_type ' => 'file ' ])
1633
+ );
1634
+ }
1635
+
1636
+ /**
1637
+ * @test
1638
+ */
1639
+ public function shouldAddVariableWithEnvironmentFromParameterList (): void
1640
+ {
1641
+ $ expectedArray = [
1642
+ 'key ' => 'DEPLOY_SERVER ' ,
1643
+ 'value ' => 'stage.example.com ' ,
1644
+ 'environment_scope ' => 'staging ' ,
1645
+ ];
1646
+
1647
+ $ api = $ this ->getApiMock ();
1648
+ $ api ->expects ($ this ->once ())
1649
+ ->method ('post ' )
1650
+ ->with ('projects/1/variables ' , $ expectedArray )
1651
+ ->will ($ this ->returnValue ($ expectedArray ));
1652
+
1653
+ $ this ->assertEquals (
1654
+ $ expectedArray ,
1655
+ $ api ->addVariable (1 , 'DEPLOY_SERVER ' , 'stage.example.com ' , null , 'staging ' , ['environment_scope ' => 'production ' ])
1656
+ );
1657
+ }
1658
+
1612
1659
/**
1613
1660
* @test
1614
1661
*/
@@ -1704,6 +1751,59 @@ public function shouldUpdateVariableWithProtectedAndEnvironment(): void
1704
1751
);
1705
1752
}
1706
1753
1754
+ /**
1755
+ * @test
1756
+ */
1757
+ public function shouldUpdateVariableWithEnvironmentAndVariableType (): void
1758
+ {
1759
+ $ expectedArray = [
1760
+ 'key ' => 'DEPLOY_SERVER ' ,
1761
+ 'value ' => 'stage.example.com ' ,
1762
+ 'environment_scope ' => 'staging ' ,
1763
+ 'variable_type ' => 'file ' ,
1764
+ ];
1765
+
1766
+ $ api = $ this ->getApiMock ();
1767
+ $ api ->expects ($ this ->once ())
1768
+ ->method ('put ' )
1769
+ ->with (
1770
+ 'projects/1/variables/DEPLOY_SERVER ' ,
1771
+ ['value ' => 'stage.example.com ' , 'environment_scope ' => 'staging ' , 'variable_type ' => 'file ' ]
1772
+ )
1773
+ ->will ($ this ->returnValue ($ expectedArray ));
1774
+
1775
+ $ this ->assertEquals (
1776
+ $ expectedArray ,
1777
+ $ api ->updateVariable (1 , 'DEPLOY_SERVER ' , 'stage.example.com ' , null , 'staging ' , ['variable_type ' => 'file ' ])
1778
+ );
1779
+ }
1780
+
1781
+ /**
1782
+ * @test
1783
+ */
1784
+ public function shouldUpdateVariableWithEnvironmentFromParameterList (): void
1785
+ {
1786
+ $ expectedArray = [
1787
+ 'key ' => 'DEPLOY_SERVER ' ,
1788
+ 'value ' => 'stage.example.com ' ,
1789
+ 'environment_scope ' => 'staging ' ,
1790
+ ];
1791
+
1792
+ $ api = $ this ->getApiMock ();
1793
+ $ api ->expects ($ this ->once ())
1794
+ ->method ('put ' )
1795
+ ->with (
1796
+ 'projects/1/variables/DEPLOY_SERVER ' ,
1797
+ ['value ' => 'stage.example.com ' , 'environment_scope ' => 'staging ' ]
1798
+ )
1799
+ ->will ($ this ->returnValue ($ expectedArray ));
1800
+
1801
+ $ this ->assertEquals (
1802
+ $ expectedArray ,
1803
+ $ api ->updateVariable (1 , 'DEPLOY_SERVER ' , 'stage.example.com ' , null , 'staging ' , ['environment_scope ' => 'production ' ])
1804
+ );
1805
+ }
1806
+
1707
1807
/**
1708
1808
* @test
1709
1809
*/
0 commit comments