From 1f4f6024cc2e217278d66e94b638880fac7f02dc Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 9 Jul 2017 12:29:18 -0500 Subject: [PATCH] Refactor (again) --- .../{ApiKeyService.php => Api/KeyService.php} | 10 +++++----- .../PermissionService.php} | 4 ++-- .../DatabaseHostService.php | 2 +- .../{Administrative => }/LocationService.php | 2 +- .../{Administrative => }/UserService.php | 2 +- .../KeyServiceTest.php} | 18 +++++++++--------- .../PermissionServiceTest.php} | 8 ++++---- .../DatabaseHostServiceTest.php | 4 ++-- .../LocationServiceTest.php | 4 ++-- .../{Administrative => }/UserServiceTest.php | 4 ++-- 10 files changed, 29 insertions(+), 29 deletions(-) rename app/Services/{ApiKeyService.php => Api/KeyService.php} (95%) rename app/Services/{ApiPermissionService.php => Api/PermissionService.php} (97%) rename app/Services/{Administrative => Database}/DatabaseHostService.php (98%) rename app/Services/{Administrative => }/LocationService.php (98%) rename app/Services/{Administrative => }/UserService.php (99%) rename tests/Unit/Services/{ApiKeyServiceTest.php => Api/KeyServiceTest.php} (89%) rename tests/Unit/Services/{ApiPermissionServiceTest.php => Api/PermissionServiceTest.php} (92%) rename tests/Unit/Services/{Administrative => Database}/DatabaseHostServiceTest.php (98%) rename tests/Unit/Services/{Administrative => }/LocationServiceTest.php (96%) rename tests/Unit/Services/{Administrative => }/UserServiceTest.php (98%) diff --git a/app/Services/ApiKeyService.php b/app/Services/Api/KeyService.php similarity index 95% rename from app/Services/ApiKeyService.php rename to app/Services/Api/KeyService.php index d4a3c6e2f..4bf03da58 100644 --- a/app/Services/ApiKeyService.php +++ b/app/Services/Api/KeyService.php @@ -22,13 +22,13 @@ * SOFTWARE. */ -namespace Pterodactyl\Services; +namespace Pterodactyl\Services\Api; use Illuminate\Database\ConnectionInterface; use Illuminate\Contracts\Encryption\Encrypter; use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface; -class ApiKeyService +class KeyService { const PUB_CRYPTO_BYTES = 8; const PRIV_CRYPTO_BYTES = 32; @@ -44,7 +44,7 @@ class ApiKeyService protected $encrypter; /** - * @var \Pterodactyl\Services\ApiPermissionService + * @var \Pterodactyl\Services\Api\PermissionService */ protected $permissionService; @@ -59,13 +59,13 @@ class ApiKeyService * @param \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface $repository * @param \Illuminate\Database\ConnectionInterface $database * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter - * @param \Pterodactyl\Services\ApiPermissionService $permissionService + * @param \Pterodactyl\Services\Api\PermissionService $permissionService */ public function __construct( ApiKeyRepositoryInterface $repository, ConnectionInterface $database, Encrypter $encrypter, - ApiPermissionService $permissionService + PermissionService $permissionService ) { $this->repository = $repository; $this->database = $database; diff --git a/app/Services/ApiPermissionService.php b/app/Services/Api/PermissionService.php similarity index 97% rename from app/Services/ApiPermissionService.php rename to app/Services/Api/PermissionService.php index 40ca4a1c9..a669c7262 100644 --- a/app/Services/ApiPermissionService.php +++ b/app/Services/Api/PermissionService.php @@ -22,11 +22,11 @@ * SOFTWARE. */ -namespace Pterodactyl\Services; +namespace Pterodactyl\Services\Api; use Pterodactyl\Contracts\Repository\ApiPermissionRepositoryInterface; -class ApiPermissionService +class PermissionService { /** * @var \Pterodactyl\Contracts\Repository\ApiPermissionRepositoryInterface diff --git a/app/Services/Administrative/DatabaseHostService.php b/app/Services/Database/DatabaseHostService.php similarity index 98% rename from app/Services/Administrative/DatabaseHostService.php rename to app/Services/Database/DatabaseHostService.php index 24acd63a3..b0dbb157d 100644 --- a/app/Services/Administrative/DatabaseHostService.php +++ b/app/Services/Database/DatabaseHostService.php @@ -22,7 +22,7 @@ * SOFTWARE. */ -namespace Pterodactyl\Services\Administrative; +namespace Pterodactyl\Services\Database; use Illuminate\Database\DatabaseManager; use Illuminate\Contracts\Encryption\Encrypter; diff --git a/app/Services/Administrative/LocationService.php b/app/Services/LocationService.php similarity index 98% rename from app/Services/Administrative/LocationService.php rename to app/Services/LocationService.php index ae050ce3d..2bf7a41e3 100644 --- a/app/Services/Administrative/LocationService.php +++ b/app/Services/LocationService.php @@ -22,7 +22,7 @@ * SOFTWARE. */ -namespace Pterodactyl\Services\Administrative; +namespace Pterodactyl\Services; use Pterodactyl\Contracts\Repository\LocationRepositoryInterface; diff --git a/app/Services/Administrative/UserService.php b/app/Services/UserService.php similarity index 99% rename from app/Services/Administrative/UserService.php rename to app/Services/UserService.php index a7503b6b2..a7c87c573 100644 --- a/app/Services/Administrative/UserService.php +++ b/app/Services/UserService.php @@ -22,7 +22,7 @@ * SOFTWARE. */ -namespace Pterodactyl\Services\Administrative; +namespace Pterodactyl\Services; use Illuminate\Foundation\Application; use Illuminate\Contracts\Hashing\Hasher; diff --git a/tests/Unit/Services/ApiKeyServiceTest.php b/tests/Unit/Services/Api/KeyServiceTest.php similarity index 89% rename from tests/Unit/Services/ApiKeyServiceTest.php rename to tests/Unit/Services/Api/KeyServiceTest.php index e48ead4ca..ef48277ad 100644 --- a/tests/Unit/Services/ApiKeyServiceTest.php +++ b/tests/Unit/Services/Api/KeyServiceTest.php @@ -22,18 +22,18 @@ * SOFTWARE. */ -namespace Tests\Unit\Services; +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\ApiKeyService; -use Pterodactyl\Services\ApiPermissionService; +use Pterodactyl\Services\Api\KeyService; +use Pterodactyl\Services\Api\PermissionService; use Tests\TestCase; -class ApiKeyServiceTest extends TestCase +class KeyServiceTest extends TestCase { use PHPMock; @@ -48,7 +48,7 @@ class ApiKeyServiceTest extends TestCase protected $encrypter; /** - * @var \Pterodactyl\Services\ApiPermissionService + * @var \Pterodactyl\Services\Api\PermissionService */ protected $permissions; @@ -58,7 +58,7 @@ class ApiKeyServiceTest extends TestCase protected $repository; /** - * @var \Pterodactyl\Services\ApiKeyService + * @var \Pterodactyl\Services\Api\KeyService */ protected $service; @@ -68,10 +68,10 @@ class ApiKeyServiceTest extends TestCase $this->database = m::mock(ConnectionInterface::class); $this->encrypter = m::mock(Encrypter::class); - $this->permissions = m::mock(ApiPermissionService::class); + $this->permissions = m::mock(PermissionService::class); $this->repository = m::mock(ApiKeyRepositoryInterface::class); - $this->service = new ApiKeyService( + $this->service = new KeyService( $this->repository, $this->database, $this->encrypter, $this->permissions ); } @@ -81,7 +81,7 @@ class ApiKeyServiceTest extends TestCase */ public function test_create_function() { - $this->getFunctionMock('\\Pterodactyl\\Services', 'random_bytes') + $this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'random_bytes') ->expects($this->exactly(2)) ->willReturnCallback(function ($bytes) { return hex2bin(str_pad('', $bytes * 2, '0')); diff --git a/tests/Unit/Services/ApiPermissionServiceTest.php b/tests/Unit/Services/Api/PermissionServiceTest.php similarity index 92% rename from tests/Unit/Services/ApiPermissionServiceTest.php rename to tests/Unit/Services/Api/PermissionServiceTest.php index 8e730623c..5c687c9b3 100644 --- a/tests/Unit/Services/ApiPermissionServiceTest.php +++ b/tests/Unit/Services/Api/PermissionServiceTest.php @@ -27,10 +27,10 @@ namespace Tests\Unit\Services; use Mockery as m; use Pterodactyl\Contracts\Repository\ApiPermissionRepositoryInterface; use Pterodactyl\Models\APIPermission; -use Pterodactyl\Services\ApiPermissionService; +use Pterodactyl\Services\Api\PermissionService; use Tests\TestCase; -class ApiPermissionServiceTest extends TestCase +class PermissionServiceTest extends TestCase { /** * @var \Pterodactyl\Contracts\Repository\ApiPermissionRepositoryInterface @@ -38,7 +38,7 @@ class ApiPermissionServiceTest extends TestCase protected $repository; /** - * @var \Pterodactyl\Services\ApiPermissionService + * @var \Pterodactyl\Services\Api\PermissionService */ protected $service; @@ -50,7 +50,7 @@ class ApiPermissionServiceTest extends TestCase parent::setUp(); $this->repository = m::mock(ApiPermissionRepositoryInterface::class); - $this->service = new ApiPermissionService($this->repository); + $this->service = new PermissionService($this->repository); } /** diff --git a/tests/Unit/Services/Administrative/DatabaseHostServiceTest.php b/tests/Unit/Services/Database/DatabaseHostServiceTest.php similarity index 98% rename from tests/Unit/Services/Administrative/DatabaseHostServiceTest.php rename to tests/Unit/Services/Database/DatabaseHostServiceTest.php index 0d4e31be3..55a97ae33 100644 --- a/tests/Unit/Services/Administrative/DatabaseHostServiceTest.php +++ b/tests/Unit/Services/Database/DatabaseHostServiceTest.php @@ -30,7 +30,7 @@ use Illuminate\Database\DatabaseManager; use Illuminate\Contracts\Encryption\Encrypter; use Pterodactyl\Extensions\DynamicDatabaseConnection; use Pterodactyl\Contracts\Repository\DatabaseHostInterface; -use Pterodactyl\Services\Administrative\DatabaseHostService; +use Pterodactyl\Services\Database\DatabaseHostService; class DatabaseHostServiceTest extends TestCase { @@ -55,7 +55,7 @@ class DatabaseHostServiceTest extends TestCase protected $repository; /** - * @var \Pterodactyl\Services\Administrative\DatabaseHostService + * @var \Pterodactyl\Services\Database\DatabaseHostService */ protected $service; diff --git a/tests/Unit/Services/Administrative/LocationServiceTest.php b/tests/Unit/Services/LocationServiceTest.php similarity index 96% rename from tests/Unit/Services/Administrative/LocationServiceTest.php rename to tests/Unit/Services/LocationServiceTest.php index 1feda6f1a..442b02b58 100644 --- a/tests/Unit/Services/Administrative/LocationServiceTest.php +++ b/tests/Unit/Services/LocationServiceTest.php @@ -26,7 +26,7 @@ namespace Tests\Unit\Services; use Mockery as m; use Tests\TestCase; -use Pterodactyl\Services\Administrative\LocationService; +use Pterodactyl\Services\LocationService; use Pterodactyl\Contracts\Repository\LocationRepositoryInterface; class LocationServiceTest extends TestCase @@ -37,7 +37,7 @@ class LocationServiceTest extends TestCase protected $repository; /** - * @var \Pterodactyl\Services\Administrative\LocationService + * @var \Pterodactyl\Services\LocationService */ protected $service; diff --git a/tests/Unit/Services/Administrative/UserServiceTest.php b/tests/Unit/Services/UserServiceTest.php similarity index 98% rename from tests/Unit/Services/Administrative/UserServiceTest.php rename to tests/Unit/Services/UserServiceTest.php index a80a277f4..f02c56525 100644 --- a/tests/Unit/Services/Administrative/UserServiceTest.php +++ b/tests/Unit/Services/UserServiceTest.php @@ -31,7 +31,7 @@ use Illuminate\Contracts\Hashing\Hasher; use Illuminate\Database\ConnectionInterface; use Illuminate\Notifications\ChannelManager; use Pterodactyl\Notifications\AccountCreated; -use Pterodactyl\Services\Administrative\UserService; +use Pterodactyl\Services\UserService; use Pterodactyl\Services\Helpers\TemporaryPasswordService; use Pterodactyl\Contracts\Repository\UserRepositoryInterface; @@ -68,7 +68,7 @@ class UserServiceTest extends TestCase protected $repository; /** - * @var \Pterodactyl\Services\Administrative\UserService + * @var \Pterodactyl\Services\UserService */ protected $service;