Begin moving packs to new service mechanisms, refactor exceptions for services
This commit is contained in:
parent
46cb71e69d
commit
9d3dca87f2
62 changed files with 492 additions and 303 deletions
|
@ -99,6 +99,9 @@ class DatabaseControllerTest extends TestCase
|
|||
$this->assertViewKeyEquals('hosts', 'getWithViewDetails', $view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the view controller for displaying a specific database host.
|
||||
*/
|
||||
public function testViewController()
|
||||
{
|
||||
$this->locationRepository->shouldReceive('getAllWithNodes')->withNoArgs()->once()->andReturn('getAllWithNodes');
|
||||
|
|
|
@ -71,7 +71,7 @@ class AssignmentServiceTest extends TestCase
|
|||
//
|
||||
// This can also be avoided if tests were run in isolated processes, or if that test
|
||||
// came first, but neither of those are good solutions, so this is the next best option.
|
||||
PHPMock::defineFunctionMock('\\Pterodactyl\\Services\\Allocations', 'gethostbyname');
|
||||
PHPMock::defineFunctionMock('\\Pterodactyl\\Service\\Allocations', 'gethostbyname');
|
||||
|
||||
$this->node = factory(Node::class)->make();
|
||||
$this->connection = m::mock(ConnectionInterface::class);
|
||||
|
@ -180,7 +180,7 @@ class AssignmentServiceTest extends TestCase
|
|||
'allocation_ports' => ['1024'],
|
||||
];
|
||||
|
||||
$this->getFunctionMock('\\Pterodactyl\\Services\\Allocations', 'gethostbyname')
|
||||
$this->getFunctionMock('\\Pterodactyl\\Service\\Allocations', 'gethostbyname')
|
||||
->expects($this->once())->willReturn('192.168.1.1');
|
||||
|
||||
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
|
||||
|
|
|
@ -81,7 +81,7 @@ class KeyServiceTest extends TestCase
|
|||
*/
|
||||
public function test_create_function()
|
||||
{
|
||||
$this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'random_bytes')
|
||||
$this->getFunctionMock('\\Pterodactyl\\Service\\Api', 'random_bytes')
|
||||
->expects($this->exactly(2))
|
||||
->willReturnCallback(function ($bytes) {
|
||||
return hex2bin(str_pad('', $bytes * 2, '0'));
|
||||
|
|
|
@ -84,7 +84,7 @@ class DatabaseManagementServiceTest extends TestCase
|
|||
$this->encrypter = m::mock(Encrypter::class);
|
||||
$this->repository = m::mock(DatabaseRepositoryInterface::class);
|
||||
|
||||
$this->getFunctionMock('\\Pterodactyl\\Services\\Database', 'str_random')
|
||||
$this->getFunctionMock('\\Pterodactyl\\Service\\Database', 'str_random')
|
||||
->expects($this->any())->willReturn('str_random');
|
||||
|
||||
$this->service = new DatabaseManagementService(
|
||||
|
|
|
@ -61,7 +61,7 @@ class CreationServiceTest extends TestCase
|
|||
*/
|
||||
public function testNodeIsCreatedAndDaemonSecretIsGenerated()
|
||||
{
|
||||
$this->getFunctionMock('\\Pterodactyl\\Services\\Nodes', 'bin2hex')
|
||||
$this->getFunctionMock('\\Pterodactyl\\Service\\Nodes', 'bin2hex')
|
||||
->expects($this->once())->willReturn('hexResult');
|
||||
|
||||
$this->repository->shouldReceive('create')->with([
|
||||
|
|
|
@ -97,14 +97,14 @@ class UpdateServiceTest extends TestCase
|
|||
*/
|
||||
public function testNodeIsUpdatedAndDaemonSecretIsReset()
|
||||
{
|
||||
$this->getFunctionMock('\\Pterodactyl\\Services\\Nodes', 'random_bytes')
|
||||
$this->getFunctionMock('\\Pterodactyl\\Service\\Nodes', 'random_bytes')
|
||||
->expects($this->once())->willReturnCallback(function ($bytes) {
|
||||
$this->assertEquals(CreationService::DAEMON_SECRET_LENGTH, $bytes);
|
||||
|
||||
return '\00';
|
||||
});
|
||||
|
||||
$this->getFunctionMock('\\Pterodactyl\\Services\\Nodes', 'bin2hex')
|
||||
$this->getFunctionMock('\\Pterodactyl\\Service\\Nodes', 'bin2hex')
|
||||
->expects($this->once())->willReturn('hexResponse');
|
||||
|
||||
$this->repository->shouldReceive('withoutFresh')->withNoArgs()->once()->andReturnSelf()
|
||||
|
|
|
@ -155,7 +155,7 @@ class CreationServiceTest extends TestCase
|
|||
$this->uuid = m::mock('overload:Ramsey\Uuid\Uuid');
|
||||
$this->writer = m::mock(Writer::class);
|
||||
|
||||
$this->getFunctionMock('\\Pterodactyl\\Services\\Servers', 'bin2hex')
|
||||
$this->getFunctionMock('\\Pterodactyl\\Service\\Servers', 'bin2hex')
|
||||
->expects($this->any())->willReturn('randomstring');
|
||||
|
||||
$this->getFunctionMock('\\Ramsey\\Uuid\\Uuid', 'uuid4')
|
||||
|
|
|
@ -84,7 +84,7 @@ class DetailsModificationServiceTest extends TestCase
|
|||
$this->repository = m::mock(ServerRepository::class);
|
||||
$this->writer = m::mock(Writer::class);
|
||||
|
||||
$this->getFunctionMock('\\Pterodactyl\\Services\\Servers', 'bin2hex')
|
||||
$this->getFunctionMock('\\Pterodactyl\\Service\\Servers', 'bin2hex')
|
||||
->expects($this->any())->willReturn('randomString');
|
||||
|
||||
$this->service = new DetailsModificationService(
|
||||
|
|
|
@ -46,10 +46,10 @@ class UsernameGenerationServiceTest extends TestCase
|
|||
|
||||
$this->service = new UsernameGenerationService();
|
||||
|
||||
$this->getFunctionMock('\\Pterodactyl\\Services\\Servers', 'bin2hex')
|
||||
$this->getFunctionMock('\\Pterodactyl\\Service\\Servers', 'bin2hex')
|
||||
->expects($this->any())->willReturn('dddddddd');
|
||||
|
||||
$this->getFunctionMock('\\Pterodactyl\\Services\\Servers', 'str_random')
|
||||
$this->getFunctionMock('\\Pterodactyl\\Service\\Servers', 'str_random')
|
||||
->expects($this->any())->willReturnCallback(function ($count) {
|
||||
return str_pad('', $count, 'a');
|
||||
});
|
||||
|
|
|
@ -30,7 +30,7 @@ use Tests\TestCase;
|
|||
use Pterodactyl\Models\ServiceOption;
|
||||
use Pterodactyl\Services\Services\Options\InstallScriptUpdateService;
|
||||
use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Services\ServiceOption\InvalidCopyFromException;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\InvalidCopyFromException;
|
||||
|
||||
class InstallScriptUpdateServiceTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ use Tests\TestCase;
|
|||
use Pterodactyl\Models\ServiceOption;
|
||||
use Pterodactyl\Services\Services\Options\OptionCreationService;
|
||||
use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Services\ServiceOption\NoParentConfigurationFoundException;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException;
|
||||
|
||||
class OptionCreationServiceTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Tests\Unit\Services\Services\Options;
|
|||
|
||||
use Mockery as m;
|
||||
use Tests\TestCase;
|
||||
use Pterodactyl\Exceptions\Services\HasActiveServersException;
|
||||
use Pterodactyl\Exceptions\Service\HasActiveServersException;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Services\Services\Options\OptionDeletionService;
|
||||
use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface;
|
||||
|
|
|
@ -30,7 +30,7 @@ use Tests\TestCase;
|
|||
use Pterodactyl\Models\ServiceOption;
|
||||
use Pterodactyl\Services\Services\Options\OptionUpdateService;
|
||||
use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Services\ServiceOption\NoParentConfigurationFoundException;
|
||||
use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException;
|
||||
|
||||
class OptionUpdateServiceTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ use Exception;
|
|||
use Mockery as m;
|
||||
use Tests\TestCase;
|
||||
use Pterodactyl\Services\Services\ServiceDeletionService;
|
||||
use Pterodactyl\Exceptions\Services\HasActiveServersException;
|
||||
use Pterodactyl\Exceptions\Service\HasActiveServersException;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface;
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ class VariableCreationServiceTest extends TestCase
|
|||
* Test that all of the reserved variables defined in the model trigger an exception.
|
||||
*
|
||||
* @dataProvider reservedNamesProvider
|
||||
* @expectedException \Pterodactyl\Exceptions\Services\ServiceVariable\ReservedVariableNameException
|
||||
* @expectedException \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException
|
||||
*/
|
||||
public function testExceptionIsThrownIfEnvironmentVariableIsInListOfReservedNames($variable)
|
||||
{
|
||||
|
|
|
@ -126,7 +126,7 @@ class VariableUpdateServiceTest extends TestCase
|
|||
* Test that all of the reserved variables defined in the model trigger an exception.
|
||||
*
|
||||
* @dataProvider reservedNamesProvider
|
||||
* @expectedException \Pterodactyl\Exceptions\Services\ServiceVariable\ReservedVariableNameException
|
||||
* @expectedException \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException
|
||||
*/
|
||||
public function testExceptionIsThrownIfEnvironmentVariableIsInListOfReservedNames($variable)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue