Apply fixes from StyleCI (#577)
This commit is contained in:
parent
4da7922de6
commit
a4b61846ac
44 changed files with 198 additions and 201 deletions
|
@ -24,14 +24,14 @@
|
|||
|
||||
namespace Tests\Unit\Services\Api;
|
||||
|
||||
use Illuminate\Contracts\Encryption\Encrypter;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Mockery as m;
|
||||
use phpmock\phpunit\PHPMock;
|
||||
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
|
||||
use Pterodactyl\Services\Api\KeyService;
|
||||
use Pterodactyl\Services\Api\PermissionService;
|
||||
use Tests\TestCase;
|
||||
use phpmock\phpunit\PHPMock;
|
||||
use Pterodactyl\Services\Api\KeyService;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Contracts\Encryption\Encrypter;
|
||||
use Pterodactyl\Services\Api\PermissionService;
|
||||
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
|
||||
|
||||
class KeyServiceTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
namespace Tests\Unit\Services;
|
||||
|
||||
use Mockery as m;
|
||||
use Pterodactyl\Contracts\Repository\ApiPermissionRepositoryInterface;
|
||||
use Tests\TestCase;
|
||||
use Pterodactyl\Models\APIPermission;
|
||||
use Pterodactyl\Services\Api\PermissionService;
|
||||
use Tests\TestCase;
|
||||
use Pterodactyl\Contracts\Repository\ApiPermissionRepositoryInterface;
|
||||
|
||||
class PermissionServiceTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -156,7 +156,7 @@ class DatabaseHostServiceTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that passing no or empty password will skip storing it
|
||||
* Test that passing no or empty password will skip storing it.
|
||||
*/
|
||||
public function test_update_without_password()
|
||||
{
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
namespace Tests\Unit\Services\Nodes;
|
||||
|
||||
use Mockery as m;
|
||||
use phpmock\phpunit\PHPMock;
|
||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||
use Pterodactyl\Services\Nodes\CreationService;
|
||||
use Tests\TestCase;
|
||||
use phpmock\phpunit\PHPMock;
|
||||
use Pterodactyl\Services\Nodes\CreationService;
|
||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||
|
||||
class CreationServiceTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
|
||||
namespace Tests\Unit\Services\Nodes;
|
||||
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
use Mockery as m;
|
||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Tests\TestCase;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Services\Nodes\DeletionService;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
|
||||
class DeletionServiceTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -25,17 +25,17 @@
|
|||
namespace Tests\Unit\Services\Nodes;
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Illuminate\Log\Writer;
|
||||
use Mockery as m;
|
||||
use phpmock\phpunit\PHPMock;
|
||||
use Pterodactyl\Contracts\Repository\Daemon\ConfigurationRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Services\Nodes\CreationService;
|
||||
use Pterodactyl\Services\Nodes\UpdateService;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Log\Writer;
|
||||
use phpmock\phpunit\PHPMock;
|
||||
use Pterodactyl\Models\Node;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Services\Nodes\UpdateService;
|
||||
use Pterodactyl\Services\Nodes\CreationService;
|
||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\Daemon\ConfigurationRepositoryInterface;
|
||||
|
||||
class UpdateServiceTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -25,13 +25,13 @@
|
|||
namespace Tests\Unit\Services\Servers;
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Illuminate\Log\Writer;
|
||||
use Mockery as m;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Services\Servers\ContainerRebuildService;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Log\Writer;
|
||||
use Pterodactyl\Models\Server;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Services\Servers\ContainerRebuildService;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface;
|
||||
|
||||
|
@ -133,7 +133,7 @@ class ContainerRebuildServiceTest extends TestCase
|
|||
} catch (Exception $exception) {
|
||||
$this->assertInstanceOf(DisplayException::class, $exception);
|
||||
$this->assertEquals(
|
||||
trans('admin/server.exceptions.daemon_exception', ['code' => 400,]), $exception->getMessage()
|
||||
trans('admin/server.exceptions.daemon_exception', ['code' => 400]), $exception->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,20 +24,20 @@
|
|||
|
||||
namespace Tests\Unit\Services\Servers;
|
||||
|
||||
use Illuminate\Log\Writer;
|
||||
use Mockery as m;
|
||||
use phpmock\phpunit\PHPMock;
|
||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||
use Pterodactyl\Services\Servers\CreationService;
|
||||
use Pterodactyl\Services\Servers\UsernameGenerationService;
|
||||
use Pterodactyl\Services\Servers\VariableValidatorService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Tests\TestCase;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Illuminate\Log\Writer;
|
||||
use phpmock\phpunit\PHPMock;
|
||||
use Illuminate\Database\DatabaseManager;
|
||||
use Pterodactyl\Services\Servers\CreationService;
|
||||
use Pterodactyl\Services\Servers\VariableValidatorService;
|
||||
use Pterodactyl\Services\Servers\UsernameGenerationService;
|
||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface;
|
||||
|
||||
class CreationServiceTest extends TestCase
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
namespace Tests\Unit\Services\Servers;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Log\Writer;
|
||||
use Mockery as m;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Log\Writer;
|
||||
use phpmock\phpunit\PHPMock;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Database\DatabaseManager;
|
||||
|
@ -258,7 +258,7 @@ class DetailsModificationServiceTest extends TestCase
|
|||
} catch (Exception $exception) {
|
||||
$this->assertInstanceOf(DisplayException::class, $exception);
|
||||
$this->assertEquals(
|
||||
trans('admin/server.exceptions.daemon_exception', ['code' => 400,]), $exception->getMessage()
|
||||
trans('admin/server.exceptions.daemon_exception', ['code' => 400]), $exception->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ class DetailsModificationServiceTest extends TestCase
|
|||
} catch (Exception $exception) {
|
||||
$this->assertInstanceOf(DisplayException::class, $exception);
|
||||
$this->assertEquals(
|
||||
trans('admin/server.exceptions.daemon_exception', ['code' => 400,]), $exception->getMessage()
|
||||
trans('admin/server.exceptions.daemon_exception', ['code' => 400]), $exception->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,14 +25,14 @@
|
|||
namespace Tests\Unit\Services\Servers;
|
||||
|
||||
use Exception;
|
||||
use Mockery as m;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Log\Writer;
|
||||
use Pterodactyl\Models\Server;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Log\Writer;
|
||||
use Mockery as m;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Services\Servers\ReinstallService;
|
||||
use Tests\TestCase;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface;
|
||||
|
||||
|
@ -162,7 +162,7 @@ class ReinstallServiceTest extends TestCase
|
|||
} catch (Exception $exception) {
|
||||
$this->assertInstanceOf(DisplayException::class, $exception);
|
||||
$this->assertEquals(
|
||||
trans('admin/server.exceptions.daemon_exception', ['code' => 400,]), $exception->getMessage()
|
||||
trans('admin/server.exceptions.daemon_exception', ['code' => 400]), $exception->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,16 +25,16 @@
|
|||
namespace Tests\Unit\Services\Servers;
|
||||
|
||||
use Exception;
|
||||
use Mockery as m;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Log\Writer;
|
||||
use Pterodactyl\Models\Server;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Log\Writer;
|
||||
use Mockery as m;
|
||||
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Services\Servers\SuspensionService;
|
||||
use Tests\TestCase;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface;
|
||||
|
||||
class SuspensionServiceTest extends TestCase
|
||||
{
|
||||
|
@ -127,9 +127,8 @@ class SuspensionServiceTest extends TestCase
|
|||
$this->assertTrue($this->service->toggle($this->server));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that server is unsuspended if action=unsuspend
|
||||
* Test that server is unsuspended if action=unsuspend.
|
||||
*/
|
||||
public function testServerShouldBeUnsuspendedWhenUnsuspendActionIsPassed()
|
||||
{
|
||||
|
@ -148,7 +147,7 @@ class SuspensionServiceTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that nothing happens if a server is already unsuspended and action=unsuspend
|
||||
* Test that nothing happens if a server is already unsuspended and action=unsuspend.
|
||||
*/
|
||||
public function testNoActionShouldHappenIfServerIsAlreadyUnsuspendedAndActionIsUnsuspend()
|
||||
{
|
||||
|
@ -158,7 +157,7 @@ class SuspensionServiceTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that nothing happens if a server is already suspended and action=suspend
|
||||
* Test that nothing happens if a server is already suspended and action=suspend.
|
||||
*/
|
||||
public function testNoActionShouldHappenIfServerIsAlreadySuspendedAndActionIsSuspend()
|
||||
{
|
||||
|
@ -191,7 +190,7 @@ class SuspensionServiceTest extends TestCase
|
|||
} catch (Exception $exception) {
|
||||
$this->assertInstanceOf(DisplayException::class, $exception);
|
||||
$this->assertEquals(
|
||||
trans('admin/server.exceptions.daemon_exception', ['code' => 400,]), $exception->getMessage()
|
||||
trans('admin/server.exceptions.daemon_exception', ['code' => 400]), $exception->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,15 +149,15 @@ class VariableValidatorServiceTest extends TestCase
|
|||
$this->validator->shouldReceive('make')->with([
|
||||
'variable_value' => 'Test_SomeValue_0',
|
||||
], [
|
||||
'variable_value' => $this->variables{0}->rules,
|
||||
'variable_value' => $this->variables[0]->rules,
|
||||
])->once()->andReturnSelf()
|
||||
->shouldReceive('fails')->withNoArgs()->once()->andReturn(false);
|
||||
|
||||
$response = $this->service->setFields([
|
||||
$this->variables{0}->env_variable => 'Test_SomeValue_0',
|
||||
$this->variables{1}->env_variable => 'Test_SomeValue_1',
|
||||
$this->variables{2}->env_variable => 'Test_SomeValue_2',
|
||||
$this->variables{3}->env_variable => 'Test_SomeValue_3',
|
||||
$this->variables[0]->env_variable => 'Test_SomeValue_0',
|
||||
$this->variables[1]->env_variable => 'Test_SomeValue_1',
|
||||
$this->variables[2]->env_variable => 'Test_SomeValue_2',
|
||||
$this->variables[3]->env_variable => 'Test_SomeValue_3',
|
||||
])->validate(1)->getResults();
|
||||
|
||||
$this->assertEquals(1, count($response), 'Assert response has a single item in array.');
|
||||
|
@ -166,8 +166,8 @@ class VariableValidatorServiceTest extends TestCase
|
|||
$this->assertArrayHasKey('key', $response[0]);
|
||||
$this->assertArrayHasKey('value', $response[0]);
|
||||
|
||||
$this->assertEquals($this->variables{0}->id, $response[0]['id']);
|
||||
$this->assertEquals($this->variables{0}->env_variable, $response[0]['key']);
|
||||
$this->assertEquals($this->variables[0]->id, $response[0]['id']);
|
||||
$this->assertEquals($this->variables[0]->env_variable, $response[0]['key']);
|
||||
$this->assertEquals('Test_SomeValue_0', $response[0]['value']);
|
||||
}
|
||||
|
||||
|
@ -178,32 +178,32 @@ class VariableValidatorServiceTest extends TestCase
|
|||
{
|
||||
$this->optionVariableRepository->shouldReceive('findWhere')->with([['option_id', '=', 1]])->andReturn($this->variables);
|
||||
|
||||
foreach($this->variables as $key => $variable) {
|
||||
foreach ($this->variables as $key => $variable) {
|
||||
$this->validator->shouldReceive('make')->with([
|
||||
'variable_value' => 'Test_SomeValue_' . $key,
|
||||
], [
|
||||
'variable_value' => $this->variables{$key}->rules,
|
||||
'variable_value' => $this->variables[$key]->rules,
|
||||
])->andReturnSelf()
|
||||
->shouldReceive('fails')->withNoArgs()->once()->andReturn(false);
|
||||
}
|
||||
|
||||
$response = $this->service->isAdmin()->setFields([
|
||||
$this->variables{0}->env_variable => 'Test_SomeValue_0',
|
||||
$this->variables{1}->env_variable => 'Test_SomeValue_1',
|
||||
$this->variables{2}->env_variable => 'Test_SomeValue_2',
|
||||
$this->variables{3}->env_variable => 'Test_SomeValue_3',
|
||||
$this->variables[0]->env_variable => 'Test_SomeValue_0',
|
||||
$this->variables[1]->env_variable => 'Test_SomeValue_1',
|
||||
$this->variables[2]->env_variable => 'Test_SomeValue_2',
|
||||
$this->variables[3]->env_variable => 'Test_SomeValue_3',
|
||||
])->validate(1)->getResults();
|
||||
|
||||
$this->assertEquals(4, count($response), 'Assert response has all four items in array.');
|
||||
|
||||
foreach($response as $key => $values) {
|
||||
foreach ($response as $key => $values) {
|
||||
$this->assertArrayHasKey($key, $response);
|
||||
$this->assertArrayHasKey('id', $response[$key]);
|
||||
$this->assertArrayHasKey('key', $response[$key]);
|
||||
$this->assertArrayHasKey('value', $response[$key]);
|
||||
|
||||
$this->assertEquals($this->variables{$key}->id, $response[$key]['id']);
|
||||
$this->assertEquals($this->variables{$key}->env_variable, $response[$key]['key']);
|
||||
$this->assertEquals($this->variables[$key]->id, $response[$key]['id']);
|
||||
$this->assertEquals($this->variables[$key]->env_variable, $response[$key]['key']);
|
||||
$this->assertEquals('Test_SomeValue_' . $key, $response[$key]['value']);
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ class VariableValidatorServiceTest extends TestCase
|
|||
$this->validator->shouldReceive('make')->with([
|
||||
'variable_value' => null,
|
||||
], [
|
||||
'variable_value' => $this->variables{0}->rules,
|
||||
'variable_value' => $this->variables[0]->rules,
|
||||
])->once()->andReturnSelf()
|
||||
->shouldReceive('fails')->withNoArgs()->once()->andReturn(true);
|
||||
|
||||
|
@ -227,7 +227,7 @@ class VariableValidatorServiceTest extends TestCase
|
|||
|
||||
try {
|
||||
$this->service->setFields([
|
||||
$this->variables{0}->env_variable => null,
|
||||
$this->variables[0]->env_variable => null,
|
||||
])->validate(1);
|
||||
} catch (DisplayValidationException $exception) {
|
||||
$decoded = json_decode($exception->getMessage());
|
||||
|
@ -235,7 +235,7 @@ class VariableValidatorServiceTest extends TestCase
|
|||
$this->assertEquals(0, json_last_error(), 'Assert that response is decodable JSON.');
|
||||
$this->assertObjectHasAttribute('notice', $decoded);
|
||||
$this->assertEquals(
|
||||
trans('admin/server.exceptions.bad_variable', ['name' => $this->variables{0}->name]),
|
||||
trans('admin/server.exceptions.bad_variable', ['name' => $this->variables[0]->name]),
|
||||
$decoded->notice[0]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,13 +25,13 @@
|
|||
namespace Tests\Unit\Services;
|
||||
|
||||
use Mockery as m;
|
||||
use Pterodactyl\Services\Users\CreationService;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Hashing\Hasher;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Notifications\ChannelManager;
|
||||
use Pterodactyl\Notifications\AccountCreated;
|
||||
use Pterodactyl\Services\Users\CreationService;
|
||||
use Pterodactyl\Services\Helpers\TemporaryPasswordService;
|
||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
|
||||
namespace Tests\Unit\Services\Users;
|
||||
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
use Mockery as m;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||
use Tests\TestCase;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Services\Users\DeletionService;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
|
||||
class DeletionServiceTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
|
||||
namespace Tests\Unit\Services\Users;
|
||||
|
||||
use Illuminate\Contracts\Hashing\Hasher;
|
||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||
use Pterodactyl\Services\Users\UpdateService;
|
||||
use Tests\TestCase;
|
||||
use Mockery as m;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Contracts\Hashing\Hasher;
|
||||
use Pterodactyl\Services\Users\UpdateService;
|
||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||
|
||||
class UpdateServiceTest extends TestCase
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue