Add type information to index

This commit is contained in:
philipp lang 2024-06-27 00:05:23 +02:00
parent 8609a648fd
commit f16b58dbc6
2 changed files with 9 additions and 1 deletions

View File

@ -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,
];
}
}

View File

@ -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);
}
}