fix integration tests
This commit is contained in:
parent
2948e344d2
commit
0e870ab256
|
@ -28,18 +28,6 @@ class EggTransformer extends Transformer
|
||||||
|
|
||||||
public function transform(Egg $model): array
|
public function transform(Egg $model): array
|
||||||
{
|
{
|
||||||
// Fixes PHP returning an empty array rather than an empty object.
|
|
||||||
// Removing associative = true would also fix this, but that causes
|
|
||||||
// the tests to fail and may have other undiscovered side effects.
|
|
||||||
$configFiles = json_decode($model->config_files, true);
|
|
||||||
if ($configFiles === []) {
|
|
||||||
$configFiles = new \stdClass();
|
|
||||||
}
|
|
||||||
$configStartup = json_decode($model->config_startup, true);
|
|
||||||
if ($configStartup === []) {
|
|
||||||
$configStartup = new \stdClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $model->id,
|
'id' => $model->id,
|
||||||
'uuid' => $model->uuid,
|
'uuid' => $model->uuid,
|
||||||
|
@ -53,8 +41,8 @@ class EggTransformer extends Transformer
|
||||||
'docker_image' => count($model->docker_images) > 0 ? $model->docker_images[0] : '',
|
'docker_image' => count($model->docker_images) > 0 ? $model->docker_images[0] : '',
|
||||||
'docker_images' => $model->docker_images,
|
'docker_images' => $model->docker_images,
|
||||||
'config' => [
|
'config' => [
|
||||||
'files' => $configFiles,
|
'files' => json_decode($model->config_files),
|
||||||
'startup' => $configStartup,
|
'startup' => json_decode($model->config_startup),
|
||||||
'stop' => $model->config_stop,
|
'stop' => $model->config_stop,
|
||||||
'file_denylist' => $model->file_denylist,
|
'file_denylist' => $model->file_denylist,
|
||||||
'extends' => $model->config_from,
|
'extends' => $model->config_from,
|
||||||
|
|
|
@ -57,7 +57,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
$expected = json_encode(Arr::sortRecursive($datum['attributes']));
|
$expected = json_encode(Arr::sortRecursive($datum['attributes']));
|
||||||
$actual = json_encode(Arr::sortRecursive((new EggTransformer())->transform($egg)));
|
$actual = json_encode(Arr::sortRecursive((new EggTransformer())->transform($egg)));
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertJsonStringEqualsJsonString(
|
||||||
$expected,
|
$expected,
|
||||||
$actual,
|
$actual,
|
||||||
'Unable to find JSON fragment: ' . PHP_EOL . PHP_EOL . "[{$expected}]" . PHP_EOL . PHP_EOL . 'within' . PHP_EOL . PHP_EOL . "[{$actual}]."
|
'Unable to find JSON fragment: ' . PHP_EOL . PHP_EOL . "[{$expected}]" . PHP_EOL . PHP_EOL . 'within' . PHP_EOL . PHP_EOL . "[{$actual}]."
|
||||||
|
@ -83,7 +83,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase
|
||||||
|
|
||||||
$response->assertJson([
|
$response->assertJson([
|
||||||
'object' => 'egg',
|
'object' => 'egg',
|
||||||
'attributes' => (new EggTransformer())->transform($egg),
|
'attributes' => json_decode(json_encode((new EggTransformer())->transform($egg)), true),
|
||||||
], true);
|
], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue