@@ -46,29 +46,30 @@ public function setUp()
4646 public function testVariableIsUpdatedWhenNoEnvironmentVariableIsPassed ()
4747 {
4848 $ this ->repository ->shouldReceive ('withoutFreshModel ' )->withNoArgs ()->once ()->andReturnSelf ()
49- ->shouldReceive ('update ' )->with ($ this ->model ->id , [
49+ ->shouldReceive ('update ' )->with ($ this ->model ->id , m:: subset ( [
5050 'user_viewable ' => false ,
5151 'user_editable ' => false ,
5252 'test-data ' => 'test-value ' ,
53- ])->once ()->andReturn (true );
53+ ])) ->once ()->andReturn (true );
5454
5555 $ this ->assertTrue ($ this ->service ->handle ($ this ->model , ['test-data ' => 'test-value ' ]));
5656 }
5757
5858 /**
59- * Test that a service variable ID can be passed in place of the model.
59+ * Test that a null value passed in for the default is converted to a string.
60+ *
61+ * @see https://github.com/Pterodactyl/Panel/issues/934
6062 */
61- public function testVariableIdCanBePassedInPlaceOfModel ()
63+ public function testNullDefaultValue ()
6264 {
63- $ this ->repository ->shouldReceive ('find ' )->with ($ this ->model ->id )->once ()->andReturn ($ this ->model );
6465 $ this ->repository ->shouldReceive ('withoutFreshModel ' )->withNoArgs ()->once ()->andReturnSelf ()
6566 ->shouldReceive ('update ' )->with ($ this ->model ->id , [
6667 'user_viewable ' => false ,
6768 'user_editable ' => false ,
68- 'test-data ' => 'test-value ' ,
69+ 'default_value ' => '' ,
6970 ])->once ()->andReturn (true );
7071
71- $ this ->assertTrue ($ this ->service ->handle ($ this ->model -> id , ['test-data ' => ' test-value ' ]));
72+ $ this ->assertTrue ($ this ->service ->handle ($ this ->model , ['default_value ' => null ]));
7273 }
7374
7475 /**
@@ -84,11 +85,11 @@ public function testVariableIsUpdatedWhenValidEnvironmentVariableIsPassed()
8485 ])->once ()->andReturn (0 );
8586
8687 $ this ->repository ->shouldReceive ('withoutFreshModel ' )->withNoArgs ()->once ()->andReturnSelf ()
87- ->shouldReceive ('update ' )->with ($ this ->model ->id , [
88+ ->shouldReceive ('update ' )->with ($ this ->model ->id , m:: subset ( [
8889 'user_viewable ' => false ,
8990 'user_editable ' => false ,
9091 'env_variable ' => 'TEST_VAR_123 ' ,
91- ])->once ()->andReturn (true );
92+ ])) ->once ()->andReturn (true );
9293
9394 $ this ->assertTrue ($ this ->service ->handle ($ this ->model , ['env_variable ' => 'TEST_VAR_123 ' ]));
9495 }
@@ -102,11 +103,11 @@ public function testVariableIsUpdatedWhenValidEnvironmentVariableIsPassed()
102103 public function testNullOptionValueIsPassedAsArray ()
103104 {
104105 $ this ->repository ->shouldReceive ('withoutFreshModel ' )->withNoArgs ()->once ()->andReturnSelf ()
105- ->shouldReceive ('update ' )->with ($ this ->model ->id , [
106+ ->shouldReceive ('update ' )->with ($ this ->model ->id , m:: subset ( [
106107 'user_viewable ' => false ,
107108 'user_editable ' => false ,
108109 'options ' => null ,
109- ])->once ()->andReturn (true );
110+ ])) ->once ()->andReturn (true );
110111
111112 $ this ->assertTrue ($ this ->service ->handle ($ this ->model , ['options ' => null ]));
112113 }
@@ -124,11 +125,11 @@ public function testDataPassedIntoHandlerTakesLowerPriorityThanDataSet()
124125 ])->once ()->andReturn (0 );
125126
126127 $ this ->repository ->shouldReceive ('withoutFreshModel ' )->withNoArgs ()->once ()->andReturnSelf ()
127- ->shouldReceive ('update ' )->with ($ this ->model ->id , [
128+ ->shouldReceive ('update ' )->with ($ this ->model ->id , m:: subset ( [
128129 'user_viewable ' => false ,
129130 'user_editable ' => false ,
130131 'env_variable ' => 'TEST_VAR_123 ' ,
131- ])->once ()->andReturn (true );
132+ ])) ->once ()->andReturn (true );
132133
133134 $ this ->assertTrue ($ this ->service ->handle ($ this ->model , ['user_viewable ' => 123456 , 'env_variable ' => 'TEST_VAR_123 ' ]));
134135 }
0 commit comments