2024-06-28 22:26:38 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Fileshare;
|
|
|
|
|
|
|
|
use App\Fileshare\ConnectionTypes\OwncloudConnection;
|
|
|
|
use App\Fileshare\Models\Fileshare;
|
|
|
|
use Tests\FileshareTestCase;
|
|
|
|
|
|
|
|
class FileshareFilesActionTest extends FileshareTestCase
|
|
|
|
{
|
|
|
|
public function testItGetsFilesForAConnection(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami()->withOwncloudUser('badenpowell', 'secret')
|
|
|
|
->withDirs('badenpowell', ['/pictures', '/lala']);
|
|
|
|
|
|
|
|
$connection = Fileshare::factory()
|
|
|
|
->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
|
|
|
|
->create();
|
|
|
|
|
2024-06-28 23:56:34 +02:00
|
|
|
$this->postJson(route('api.fileshare.files', ['fileshare' => $connection]), [
|
2024-06-28 22:26:38 +02:00
|
|
|
'parent' => null,
|
2024-06-28 23:56:34 +02:00
|
|
|
])
|
|
|
|
->assertJsonCount(2, 'data')
|
|
|
|
->assertJsonPath('data.0.name', 'lala')
|
|
|
|
->assertJsonPath('data.0.path', '/lala')
|
|
|
|
->assertJsonPath('data.0.parent', '/')
|
|
|
|
->assertJsonPath('data.1.name', 'pictures')
|
|
|
|
->assertJsonPath('data.1.path', '/pictures')
|
|
|
|
->assertJsonPath('data.1.parent', '/');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItGetsSubdirectories(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami()->withOwncloudUser('badenpowell', 'secret')
|
|
|
|
->withDirs('badenpowell', ['/pictures', '/lala', '/lala/dd', '/lala/ff']);
|
|
|
|
|
|
|
|
$connection = Fileshare::factory()
|
|
|
|
->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
|
|
|
|
->create();
|
|
|
|
|
|
|
|
$this->postJson(route('api.fileshare.files', ['fileshare' => $connection]), ['parent' => '/pictures'])->assertJsonCount(0, 'data');
|
|
|
|
$this->postJson(route('api.fileshare.files', ['fileshare' => $connection]), ['parent' => '/lala'])
|
|
|
|
->assertJsonCount(2, 'data')
|
|
|
|
->assertJsonPath('data.0.name', 'dd')
|
|
|
|
->assertJsonPath('data.0.path', '/lala/dd')
|
|
|
|
->assertJsonPath('data.0.parent', '/lala')
|
|
|
|
->assertJsonPath('data.1.name', 'ff')
|
|
|
|
->assertJsonPath('data.1.path', '/lala/ff')
|
|
|
|
->assertJsonPath('data.1.parent', '/lala');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItGetsSubdirectoriesOfSubdirectory(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling()->login()->loginNami()->withOwncloudUser('badenpowell', 'secret')
|
|
|
|
->withDirs('badenpowell', ['/lala', '/lala/dd', '/lala/dd/ee']);
|
|
|
|
|
|
|
|
$connection = Fileshare::factory()
|
|
|
|
->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
|
|
|
|
->create();
|
|
|
|
|
|
|
|
$this->postJson(route('api.fileshare.files', ['fileshare' => $connection]), ['parent' => '/lala/dd'])
|
|
|
|
->assertJsonCount(1, 'data')
|
|
|
|
->assertJsonPath('data.0.name', 'ee')
|
|
|
|
->assertJsonPath('data.0.path', '/lala/dd/ee')
|
|
|
|
->assertJsonPath('data.0.parent', '/lala/dd');
|
2024-06-28 22:26:38 +02:00
|
|
|
}
|
|
|
|
}
|