adrema/tests/Feature/Group/BulkstoreTest.php

57 lines
1.9 KiB
PHP
Raw Permalink Normal View History

2023-12-30 02:02:07 +01:00
<?php
namespace Tests\Feature\Group;
2024-06-29 14:36:35 +02:00
use App\Fileshare\ConnectionTypes\OwncloudConnection;
use App\Fileshare\Models\Fileshare;
2023-12-30 02:02:07 +01:00
use App\Group;
use App\Group\Enums\Level;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class BulkstoreTest extends TestCase
{
use DatabaseTransactions;
public function testItSavesGroupsLevelAndParent(): void
{
$this->login()->loginNami()->withoutExceptionHandling();
$group = Group::factory()->for(Group::first(), 'parent')->create(['inner_name' => 'Gruppe', 'level' => Level::REGION]);
$this->postJson(route('group.bulkstore'), [
2024-06-29 14:36:35 +02:00
['id' => $group->id, 'inner_name' => 'Abc', 'level' => Level::FEDERATION->value, 'fileshare' => null]
2023-12-30 02:02:07 +01:00
])->assertOk();
2024-06-29 14:36:35 +02:00
$this->assertNull($group->fresh()->fileshare);
2023-12-30 02:02:07 +01:00
$this->assertDatabaseHas('groups', [
'id' => $group->id,
'inner_name' => 'Abc',
'level' => 'Diözese',
2024-06-29 14:36:35 +02:00
'fileshare' => null,
2023-12-30 02:02:07 +01:00
]);
}
2024-06-29 14:36:35 +02:00
public function testItStoresFileconnection(): void
{
$this->login()->loginNami()->withoutExceptionHandling();
$connection = Fileshare::factory()
->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
->name('lokaler Server')
->create();
$group = Group::factory()->for(Group::first(), 'parent')->create(['inner_name' => 'Gruppe', 'level' => Level::REGION]);
$this->postJson(route('group.bulkstore'), [
['id' => $group->id, 'inner_name' => 'Abc', 'level' => Level::FEDERATION->value, 'fileshare' => [
'connection_id' => $connection->id,
'resource' => '/abc',
]]
])->assertOk();
$this->assertEquals($connection->id, $group->fresh()->fileshare->connectionId);
$this->assertEquals('/abc', $group->fresh()->fileshare->resource);
}
2023-12-30 02:02:07 +01:00
}