From f16b58dbc6b64ed38f425c3d10189b8714a92780 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Thu, 27 Jun 2024 00:05:23 +0200 Subject: [PATCH] Add type information to index --- app/Fileshare/Resources/FileshareConnectionResource.php | 3 +++ tests/Fileshare/ConnectionIndexActionTest.php | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Fileshare/Resources/FileshareConnectionResource.php b/app/Fileshare/Resources/FileshareConnectionResource.php index 239ce241..2d444d96 100644 --- a/app/Fileshare/Resources/FileshareConnectionResource.php +++ b/app/Fileshare/Resources/FileshareConnectionResource.php @@ -17,6 +17,9 @@ class FileshareConnectionResource extends JsonResource return [ 'name' => $this->name, 'is_active' => $this->type->check(), + 'type' => get_class($this->type), + 'config' => $this->type->toArray(), + 'id' => $this->id, ]; } } diff --git a/tests/Fileshare/ConnectionIndexActionTest.php b/tests/Fileshare/ConnectionIndexActionTest.php index 21327dc6..d4d327a7 100644 --- a/tests/Fileshare/ConnectionIndexActionTest.php +++ b/tests/Fileshare/ConnectionIndexActionTest.php @@ -11,13 +11,18 @@ class ConnectionIndexActionTest extends FileshareTestCase public function testItListsOwncloudConnectionsThatAreActive(): void { $this->withoutExceptionHandling()->login()->loginNami()->withOwncloudUser('badenpowell', 'secret'); - FileshareConnection::factory() + $connection = FileshareConnection::factory() ->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')])) ->name('lokaler Server') ->create(); $this->get('/setting/fileshare') ->assertInertiaPath('data.data.0.name', 'lokaler Server') + ->assertInertiaPath('data.data.0.type', OwncloudConnection::class) + ->assertInertiaPath('data.data.0.config.user', 'badenpowell') + ->assertInertiaPath('data.data.0.config.password', 'secret') + ->assertInertiaPath('data.data.0.config.base_url', env('TEST_OWNCLOUD_DOMAIN')) + ->assertInertiaPath('data.data.0.id', $connection->id) ->assertInertiaPath('data.data.0.is_active', true); } }