First go at integration tests
This commit is contained in:
parent
89db9390df
commit
e2aa01c9cc
16 changed files with 610 additions and 28 deletions
|
@ -5,10 +5,15 @@ namespace Pterodactyl\Transformers\Api\Application;
|
|||
use Cake\Chronos\Chronos;
|
||||
use Pterodactyl\Models\ApiKey;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||
use Pterodactyl\Transformers\Api\Client\BaseClientTransformer;
|
||||
use Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException;
|
||||
|
||||
/**
|
||||
* @method array transform(Model $model)
|
||||
*/
|
||||
abstract class BaseTransformer extends TransformerAbstract
|
||||
{
|
||||
const RESPONSE_TIMEZONE = 'UTC';
|
||||
|
@ -88,7 +93,7 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
$transformer = Container::getInstance()->makeWith($abstract, $parameters);
|
||||
$transformer->setKey($this->getKey());
|
||||
|
||||
if (! $transformer instanceof self) {
|
||||
if (! $transformer instanceof self || $transformer instanceof BaseClientTransformer) {
|
||||
throw new InvalidTransformerLevelException('Calls to ' . __METHOD__ . ' must return a transformer that is an instance of ' . __CLASS__);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,13 @@ class LocationTransformer extends BaseTransformer
|
|||
*/
|
||||
public function transform(Location $location): array
|
||||
{
|
||||
return $location->toArray();
|
||||
return [
|
||||
'id' => $location->id,
|
||||
'short' => $location->short,
|
||||
'long' => $location->long,
|
||||
$location->getUpdatedAtColumn() => $this->formatTimestamp($location->updated_at),
|
||||
$location->getCreatedAtColumn() => $this->formatTimestamp($location->created_at),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,6 +46,8 @@ class LocationTransformer extends BaseTransformer
|
|||
*
|
||||
* @param \Pterodactyl\Models\Location $location
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeServers(Location $location)
|
||||
{
|
||||
|
@ -57,6 +65,8 @@ class LocationTransformer extends BaseTransformer
|
|||
*
|
||||
* @param \Pterodactyl\Models\Location $location
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeNodes(Location $location)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue