From 50ffaf4d01ee576a0094fd7a8e8952a9837c906f Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Fri, 18 Oct 2024 22:38:06 -0400 Subject: [PATCH] Fix tests --- .../Services/Servers/ServerCreationServiceTest.php | 7 +++++-- .../Servers/StartupModificationServiceTest.php | 10 +++++++--- .../Services/Servers/VariableValidatorServiceTest.php | 7 +++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/Integration/Services/Servers/ServerCreationServiceTest.php b/tests/Integration/Services/Servers/ServerCreationServiceTest.php index 9cedbfea2..7589dbe0a 100644 --- a/tests/Integration/Services/Servers/ServerCreationServiceTest.php +++ b/tests/Integration/Services/Servers/ServerCreationServiceTest.php @@ -87,6 +87,7 @@ class ServerCreationServiceTest extends IntegrationTestCase 'environment' => [ 'BUNGEE_VERSION' => '123', 'SERVER_JARFILE' => 'server2.jar', + 'SERVER_PORT' => '1234', ], 'start_on_completion' => true, ]; @@ -98,13 +99,14 @@ class ServerCreationServiceTest extends IntegrationTestCase 'environment' => [ 'BUNGEE_VERSION' => '', 'SERVER_JARFILE' => 'server2.jar', + 'SERVER_PORT' => '1234', ], ]), $deployment); $this->fail('This execution pathway should not be reached.'); } catch (ValidationException $exception) { - $this->assertCount(1, $exception->errors()); $this->assertArrayHasKey('environment.BUNGEE_VERSION', $exception->errors()); + $this->assertArrayNotHasKey('environment.SERVER_JARFILE', $exception->errors()); $this->assertSame('The Bungeecord Version variable field is required.', $exception->errors()['environment.BUNGEE_VERSION'][0]); } @@ -114,7 +116,7 @@ class ServerCreationServiceTest extends IntegrationTestCase $this->assertNotNull($response->uuid); $this->assertSame($response->uuid_short, substr($response->uuid, 0, 8)); $this->assertSame($egg->id, $response->egg_id); - $this->assertCount(2, $response->variables); + $this->assertCount(3, $response->variables); $this->assertSame('123', $response->variables[0]->server_value); $this->assertSame('server2.jar', $response->variables[1]->server_value); @@ -167,6 +169,7 @@ class ServerCreationServiceTest extends IntegrationTestCase 'environment' => [ 'BUNGEE_VERSION' => '123', 'SERVER_JARFILE' => 'server2.jar', + 'SERVER_PORT' => '1234', ], ]; diff --git a/tests/Integration/Services/Servers/StartupModificationServiceTest.php b/tests/Integration/Services/Servers/StartupModificationServiceTest.php index f0d2726e1..803a98486 100644 --- a/tests/Integration/Services/Servers/StartupModificationServiceTest.php +++ b/tests/Integration/Services/Servers/StartupModificationServiceTest.php @@ -29,6 +29,7 @@ class StartupModificationServiceTest extends IntegrationTestCase 'environment' => [ 'BUNGEE_VERSION' => '$$', 'SERVER_JARFILE' => 'server.jar', + 'SERVER_PORT' => '1234', ], ]); @@ -54,11 +55,12 @@ class StartupModificationServiceTest extends IntegrationTestCase 'environment' => [ 'BUNGEE_VERSION' => '1234', 'SERVER_JARFILE' => 'test.jar', + 'SERVER_PORT' => '1234', ], ]); $this->assertInstanceOf(Server::class, $result); - $this->assertCount(2, $result->variables); + $this->assertCount(3, $result->variables); $this->assertSame($server->startup, $result->startup); $this->assertSame('1234', $result->variables[0]->server_value); $this->assertSame('test.jar', $result->variables[1]->server_value); @@ -125,7 +127,7 @@ class StartupModificationServiceTest extends IntegrationTestCase ], ]); - $this->assertCount(2, $response->variables); + $this->assertCount(3, $response->variables); $this->assertSame('EXIST', $response->variables[0]->server_value); $this->assertSame('test.jar', $response->variables[1]->server_value); @@ -135,12 +137,14 @@ class StartupModificationServiceTest extends IntegrationTestCase 'environment' => [ 'BUNGEE_VERSION' => '1234', 'SERVER_JARFILE' => 'test.jar', + 'SERVER_PORT' => '1111', ], ]); - $this->assertCount(2, $response->variables); + $this->assertCount(3, $response->variables); $this->assertSame('1234', $response->variables[0]->server_value); $this->assertSame('test.jar', $response->variables[1]->server_value); + $this->assertSame('1111', $response->variables[2]->server_value); } /** diff --git a/tests/Integration/Services/Servers/VariableValidatorServiceTest.php b/tests/Integration/Services/Servers/VariableValidatorServiceTest.php index 6f49b97fb..9f70f8b0d 100644 --- a/tests/Integration/Services/Servers/VariableValidatorServiceTest.php +++ b/tests/Integration/Services/Servers/VariableValidatorServiceTest.php @@ -94,25 +94,28 @@ class VariableValidatorServiceTest extends IntegrationTestCase $this->getService()->setUserLevel(User::USER_LEVEL_ADMIN)->handle($egg->id, [ 'BUNGEE_VERSION' => '1.2.3', 'SERVER_JARFILE' => 'server.jar', + 'SERVER_PORT' => '1234', ]); $this->fail('This statement should not be reached.'); } catch (ValidationException $exception) { - $this->assertCount(1, $exception->errors()); $this->assertArrayHasKey('environment.BUNGEE_VERSION', $exception->errors()); } $response = $this->getService()->setUserLevel(User::USER_LEVEL_ADMIN)->handle($egg->id, [ 'BUNGEE_VERSION' => '123', 'SERVER_JARFILE' => 'server.jar', + 'SERVER_PORT' => '1234', ]); $this->assertInstanceOf(Collection::class, $response); - $this->assertCount(2, $response); + $this->assertCount(3, $response); $this->assertSame('BUNGEE_VERSION', $response->get(0)->key); $this->assertSame('123', $response->get(0)->value); $this->assertSame('SERVER_JARFILE', $response->get(1)->key); $this->assertSame('server.jar', $response->get(1)->value); + $this->assertSame('SERVER_PORT', $response->get(2)->key); + $this->assertSame('1234', $response->get(2)->value); } public function testNullableEnvironmentVariablesCanBeUsedCorrectly(): void