adrema/tests/Fileshare/FileshareIndexActionTest.php

44 lines
1.9 KiB
PHP
Raw Normal View History

2024-06-27 00:00:29 +02:00
<?php
namespace Tests\Fileshare;
use App\Fileshare\ConnectionTypes\OwncloudConnection;
2024-06-27 17:41:54 +02:00
use App\Fileshare\Models\Fileshare;
2024-06-27 00:00:29 +02:00
use Tests\FileshareTestCase;
2024-06-27 12:48:20 +02:00
class FileshareIndexActionTest extends FileshareTestCase
2024-06-27 00:00:29 +02:00
{
public function testItListsOwncloudConnectionsThatAreActive(): void
{
2024-07-14 00:05:53 +02:00
$this->withoutExceptionHandling()->login()->loginNami()->withUser('badenpowell', 'secret');
2024-06-27 17:41:54 +02:00
$connection = Fileshare::factory()
2024-06-27 00:00:29 +02:00
->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
->name('lokaler Server')
->create();
2024-06-27 18:04:58 +02:00
$this->get('/api/fileshare')
->assertJsonPath('data.0.name', 'lokaler Server')
->assertJsonPath('data.0.type', OwncloudConnection::class)
->assertJsonPath('data.0.config.user', 'badenpowell')
->assertJsonPath('data.0.config.password', 'secret')
->assertJsonPath('data.0.config.base_url', env('TEST_OWNCLOUD_DOMAIN'))
->assertJsonPath('data.0.id', $connection->id)
->assertJsonPath('data.0.is_active', true)
->assertJsonPath('data.0.type_human', 'Owncloud')
->assertJsonPath('data.0.links.update', route('fileshare.update', ['fileshare' => $connection]))
->assertJsonPath('meta.default.name', '')
->assertJsonPath('meta.links.store', route('fileshare.store'))
->assertJsonPath('meta.types.0.id', OwncloudConnection::class)
->assertJsonPath('meta.types.0.name', 'Owncloud')
->assertJsonPath('meta.types.0.defaults.base_url', '')
->assertJsonPath('meta.types.0.fields.1', ['label' => 'Benutzer', 'key' => 'user', 'type' => 'text']);
2024-06-27 00:00:29 +02:00
}
2024-06-27 17:50:18 +02:00
public function testItRendersComponent(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
2024-06-27 18:04:58 +02:00
$this->get('/setting/fileshare')->assertComponent('fileshare/Index');
2024-06-27 17:50:18 +02:00
}
2024-06-27 00:00:29 +02:00
}