Remove unnecessary function

This commit is contained in:
Dane Everitt 2021-08-07 14:32:40 -07:00
parent bbf2f33c5e
commit fdd90b3be7
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
37 changed files with 92 additions and 136 deletions

View file

@ -5,7 +5,6 @@ namespace Pterodactyl\Tests\Integration\Api\Application;
use Pterodactyl\Models\User;
use Pterodactyl\Models\ApiKey;
use Pterodactyl\Services\Acl\Api\AdminAcl;
use Pterodactyl\Transformers\Api\Transformer;
use Pterodactyl\Tests\Integration\IntegrationTestCase;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Pterodactyl\Tests\Traits\Integration\CreatesTestModels;
@ -122,16 +121,4 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase
'r_server_databases' => AdminAcl::READ | AdminAcl::WRITE,
], $permissions));
}
/**
* Return a transformer that can be used for testing purposes.
*
* @param string $abstract
*
* @return \Pterodactyl\Transformers\Api\Transformer
*/
protected function getTransformer(string $abstract): Transformer
{
return new $abstract;
}
}

View file

@ -56,7 +56,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
$egg = $eggs->where('id', '=', $datum['attributes']['id'])->first();
$expected = json_encode(Arr::sortRecursive($datum['attributes']));
$actual = json_encode(Arr::sortRecursive($this->getTransformer(EggTransformer::class)->transform($egg)));
$actual = json_encode(Arr::sortRecursive((new EggTransformer())->transform($egg)));
$this->assertSame(
$expected,
@ -84,7 +84,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
$response->assertJson([
'object' => 'egg',
'attributes' => $this->getTransformer(EggTransformer::class)->transform($egg),
'attributes' => (new EggTransformer())->transform($egg),
], true);
}

View file

@ -118,7 +118,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
'data' => [
[
'object' => 'node',
'attributes' => $this->getTransformer(NodeTransformer::class)->transform($server->getRelation('node')),
'attributes' => (new NodeTransformer())->transform($server->getRelation('node')),
],
],
],
@ -127,7 +127,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase
'data' => [
[
'object' => 'server',
'attributes' => $this->getTransformer(ServerTransformer::class)->transform($server),
'attributes' => (new ServerTransformer())->transform($server),
],
],
],

View file

@ -59,7 +59,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase
foreach ($nests as $nest) {
$response->assertJsonFragment([
'object' => 'nest',
'attributes' => $this->getTransformer(NestTransformer::class)->transform($nest),
'attributes' => (new NestTransformer())->transform($nest),
]);
}
}
@ -80,7 +80,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase
$response->assertJson([
'object' => 'nest',
'attributes' => $this->getTransformer(NestTransformer::class)->transform($nest),
'attributes' => (new NestTransformer())->transform($nest),
]);
}

View file

@ -140,7 +140,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
'data' => [
[
'object' => 'server',
'attributes' => $this->getTransformer(ServerTransformer::class)->transform($server),
'attributes' => (new ServerTransformer())->transform($server),
],
],
]);
@ -238,7 +238,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
$user = User::where('username', 'testuser')->first();
$response->assertJson([
'object' => 'user',
'attributes' => $this->getTransformer(UserTransformer::class)->transform($user),
'attributes' => (new UserTransformer())->transform($user),
'meta' => [
'resource' => route('api.application.users.view', $user->id),
],
@ -268,7 +268,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
$response->assertJson([
'object' => 'user',
'attributes' => $this->getTransformer(UserTransformer::class)->transform($user),
'attributes' => (new UserTransformer())->transform($user),
]);
}