adrema/tests/Fileshare/FileshareUpdateActionTest.php

57 lines
2.1 KiB
PHP
Raw Normal View History

2024-06-27 00:19:12 +02:00
<?php
namespace Tests\Fileshare;
use App\Fileshare\ConnectionTypes\OwncloudConnection;
use App\Fileshare\Models\FileshareConnection;
use Tests\FileshareTestCase;
2024-06-27 12:48:20 +02:00
class FileshareUpdateActionTest extends FileshareTestCase
2024-06-27 00:19:12 +02:00
{
public function testItStoresAConnection(): void
{
$this->withoutExceptionHandling()->login()->loginNami()->withOwncloudUser('badenpowell', 'secret');
2024-06-27 12:48:20 +02:00
$connection = FileshareConnection::factory()
->type(OwncloudConnection::from(['user' => 'test', 'password' => 'test', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
->name('lokaler Server')
->create();
$this->patch(route('fileshare.update', ['fileshare' => $connection]), [
2024-06-27 00:19:12 +02:00
'name' => 'Lala',
'type' => OwncloudConnection::class,
'config' => [
'user' => 'badenpowell',
'password' => 'secret',
'base_url' => env('TEST_OWNCLOUD_DOMAIN'),
]
])->assertOk();
$connection = FileshareConnection::firstOrFail();
$this->assertEquals('badenpowell', $connection->type->user);
$this->assertEquals('secret', $connection->type->password);
$this->assertEquals(env('TEST_OWNCLOUD_DOMAIN'), $connection->type->baseUrl);
$this->assertEquals('Lala', $connection->name);
}
public function testItChecksConnection(): void
{
2024-06-27 12:48:20 +02:00
$this->login()->loginNami()->withOwncloudUser('test', 'test');
$connection = FileshareConnection::factory()
->type(OwncloudConnection::from(['user' => 'test', 'password' => 'test', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
->name('lokaler Server')
->create();
2024-06-27 00:19:12 +02:00
2024-06-27 12:48:20 +02:00
$this->patchJson(route('fileshare.update', ['fileshare' => $connection]), [
2024-06-27 00:19:12 +02:00
'name' => 'Lala',
'type' => OwncloudConnection::class,
'config' => [
'user' => 'badenpowell',
'password' => 'secret',
'base_url' => env('TEST_OWNCLOUD_DOMAIN'),
]
])->assertJsonValidationErrors(['type' => 'Verbindung fehlgeschlagen']);
}
}