withoutExceptionHandling()->login()->loginNami(); Livewire::test(Form::class) ->assertSet('name', '') ->assertSee('Bezeichnung') ->assertSee('Owncloud') ->assertSee('Nextcloud') ->assertSet('type', []); }); it('it displays owncloud connection values', function () { test()->withoutExceptionHandling()->login()->loginNami(); Livewire::test(Form::class) ->set('typeClass', OwncloudConnection::class) ->assertSet('typeClass', OwncloudConnection::class) ->assertSee('Benutzer') ->assertSee('URL') ->assertSet('type.user', '') ->assertSet('type.base_url', '') ->assertSet('type.password', ''); }); it('it saves owncloud connection', function () { test()->login()->loginNami()->withUser('badenpowell', 'secret'); Livewire::test(Form::class) ->set('name', 'lala') ->set('typeClass', OwncloudConnection::class) ->set('type.user', 'badenpowell') ->set('type.password', 'secret') ->set('type.base_url', env('TEST_OWNCLOUD_DOMAIN')) ->call('onSave') ->assertDispatched('success', 'Verbindung erstellt.') ->assertDispatched('refresh-page'); $connection = Fileshare::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); }); it('it saves nextcloud connection', function () { test()->login()->loginNami()->withUser('badenpowell', 'secret'); Livewire::test(Form::class) ->set('name', 'lala') ->set('typeClass', NextcloudConnection::class) ->set('type.user', 'badenpowell') ->set('type.password', 'secret') ->set('type.base_url', env('TEST_OWNCLOUD_DOMAIN')) ->call('onSave') ->assertDispatched('success', 'Verbindung erstellt.') ->assertDispatched('refresh-page'); $connection = Fileshare::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); }); it('checks nextcloud connection', function () { test()->login()->loginNami()->withUser('badenpowell', 'secret'); Livewire::test(Form::class) ->set('name', 'lala') ->set('typeClass', NextcloudConnection::class) ->set('type.user', 'badenpowell') ->set('type.password', 'wrong') ->set('type.base_url', env('TEST_OWNCLOUD_DOMAIN')) ->call('onSave') ->assertHasErrors(['typeClass' => 'Verbindung fehlgeschlagen']); }); it('validates input', function ($attributes, $errors) { test()->login()->loginNami()->withUser('badenpowell', 'secret'); Livewire::test(Form::class) ->set('name', 'lala') ->set('typeClass', NextcloudConnection::class) ->set('type.user', 'badenpowell') ->set('type.password', 'wrong') ->set('type.base_url', env('TEST_OWNCLOUD_DOMAIN')) ->setArray($attributes) ->call('onSave') ->assertHasErrors($errors); })->with([ [['name' => ''], ['name' => 'Bezeichnung ist erforderlich.']], [['typeClass' => null], ['typeClass' => 'Typ ist erforderlich.']], ]); it('updates a connection', function () { $this->withoutExceptionHandling()->login()->loginNami()->withUser('badenpowell', 'secretneu'); $connection = Fileshare::factory() ->type(OwncloudConnection::from(['user' => 'test', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')])) ->name('lokaler Server') ->create(); Livewire::test(Form::class, ['id' => $connection->id]) ->assertSet('name', 'lokaler Server') ->assertSet('typeClass', OwncloudConnection::class) ->assertSet('type.user', 'test') ->assertSet('type.password', 'secret') ->assertSet('type.base_url', env('TEST_OWNCLOUD_DOMAIN')) ->setArray([ 'name' => 'Lala', 'typeClass' => OwncloudConnection::class, 'type' => [ 'user' => 'badenpowell', 'password' => 'secretneu', 'base_url' => env('TEST_OWNCLOUD_DOMAIN'), ] ]) ->call('onSave') ->assertDispatched('success', 'Verbindung aktualisiert.') ->assertDispatched('refresh-page'); $connection = Fileshare::firstOrFail(); $this->assertEquals('badenpowell', $connection->type->user); $this->assertEquals('secretneu', $connection->type->password); $this->assertEquals(env('TEST_OWNCLOUD_DOMAIN'), $connection->type->baseUrl); $this->assertEquals('Lala', $connection->name); }); it('checks a connection while updating', function () { $this->withoutExceptionHandling()->login()->loginNami()->withUser('badenpowell', 'secretneu'); $connection = Fileshare::factory() ->type(OwncloudConnection::from(['user' => 'test', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')])) ->name('lokaler Server') ->create(); Livewire::test(Form::class, ['id' => $connection->id]) ->set('type.password', 'wrong') ->call('onSave') ->assertHasErrors(['typeClass' => 'Verbindung fehlgeschlagen']); });