From 8ece5fd8c5eb8e46d34e99a7af5f1d972dfce93b Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 20 Oct 2024 18:29:32 +0200 Subject: [PATCH] Delete old mailgateway tests --- tests/Feature/Mailgateway/IndexTest.php | 92 ------------------ tests/Feature/Mailgateway/MailmanTypeTest.php | 48 ---------- tests/Feature/Mailgateway/StoreTest.php | 96 ------------------- tests/Feature/Mailgateway/UpdateTest.php | 31 ------ 4 files changed, 267 deletions(-) delete mode 100644 tests/Feature/Mailgateway/IndexTest.php delete mode 100644 tests/Feature/Mailgateway/MailmanTypeTest.php delete mode 100644 tests/Feature/Mailgateway/StoreTest.php delete mode 100644 tests/Feature/Mailgateway/UpdateTest.php diff --git a/tests/Feature/Mailgateway/IndexTest.php b/tests/Feature/Mailgateway/IndexTest.php deleted file mode 100644 index ff13ba47..00000000 --- a/tests/Feature/Mailgateway/IndexTest.php +++ /dev/null @@ -1,92 +0,0 @@ -login()->loginNami(); - } - - public function testItCanViewIndexPage(): void - { - $response = $this->get('/setting/mailgateway'); - - $response->assertOk(); - } - - public function testItDisplaysLocalGateways(): void - { - $this->withoutExceptionHandling(); - $mailgateway = Mailgateway::factory()->type(LocalType::class, [])->name('Lore')->domain('example.com')->create(); - - $response = $this->get('/setting/mailgateway'); - - $this->assertInertiaHas('example.com', $response, 'data.data.0.domain'); - $this->assertInertiaHas('Lore', $response, 'data.data.0.name'); - $this->assertInertiaHas('Lokal', $response, 'data.data.0.type_human'); - $this->assertInertiaHas(true, $response, 'data.data.0.works'); - $this->assertInertiaHas($mailgateway->id, $response, 'data.data.0.id'); - $this->assertInertiaHas(route('mailgateway.update', ['mailgateway' => $mailgateway->id]), $response, 'data.data.0.links.update'); - } - - public function testItDisplaysMailmanGateways(): void - { - $this->stubIo(MailmanService::class, function ($mock) { - Phake::when($mock)->setCredentials()->thenReturn($mock); - Phake::when($mock)->check()->thenReturn(true); - }); - $this->withoutExceptionHandling(); - Mailgateway::factory()->type(MailmanType::class, MailmanTypeRequest::new()->create())->create(); - - $this->get('/setting/mailgateway')->assertOk(); - } - - public function testItHasMeta(): void - { - $this->withoutExceptionHandling(); - - $response = $this->get('/setting/mailgateway'); - - $this->assertInertiaHas(route('mailgateway.store'), $response, 'data.meta.links.store'); - $this->assertInertiaHas([ - 'id' => null, - 'name' => '-- kein --', - ], $response, 'data.meta.types.0'); - $this->assertInertiaHas([ - 'id' => LocalType::class, - 'name' => 'Lokal', - ], $response, 'data.meta.types.1'); - $this->assertInertiaHas([ - 'id' => MailmanType::class, - 'fields' => [ - [ - 'name' => 'url', - 'is_required' => true, - ], - ], - ], $response, 'data.meta.types.2'); - $this->assertInertiaHas([ - 'domain' => '', - 'name' => '', - 'type' => [ - 'params' => [], - 'cls' => null, - ], - ], $response, 'data.meta.default'); - } -} diff --git a/tests/Feature/Mailgateway/MailmanTypeTest.php b/tests/Feature/Mailgateway/MailmanTypeTest.php deleted file mode 100644 index 487bd882..00000000 --- a/tests/Feature/Mailgateway/MailmanTypeTest.php +++ /dev/null @@ -1,48 +0,0 @@ -withoutExceptionHandling(); - $this->stubIo(MailmanService::class, function ($mock) { - Phake::when($mock)->setCredentials('https://example.com', 'user', 'secret')->thenReturn($mock); - Phake::when($mock)->check()->thenReturn(true); - Phake::when($mock)->setOwner('owner@example.com')->thenReturn($mock); - }); - $type = app(MailmanType::class)->setParams([ - 'url' => 'https://example.com', - 'user' => 'user', - 'password' => 'secret', - 'owner' => 'owner@example.com', - ]); - - $this->assertTrue($type->works()); - } - - public function testItCanReturnFalse(): void - { - $this->withoutExceptionHandling(); - $this->stubIo(MailmanService::class, function ($mock) { - Phake::when($mock)->setCredentials('https://example.com', 'user', 'secret')->thenReturn($mock); - Phake::when($mock)->check()->thenReturn(false); - }); - $type = app(MailmanType::class)->setParams([ - 'url' => 'https://example.com', - 'user' => 'user', - 'password' => 'secret', - ]); - - $this->assertFalse($type->works()); - } -} diff --git a/tests/Feature/Mailgateway/StoreTest.php b/tests/Feature/Mailgateway/StoreTest.php deleted file mode 100644 index 017b7606..00000000 --- a/tests/Feature/Mailgateway/StoreTest.php +++ /dev/null @@ -1,96 +0,0 @@ -login()->loginNami(); - } - - public function testItCanStoreALocalGateway(): void - { - $response = $this->postJson('/api/mailgateway', MailgatewayRequestFactory::new()->name('lala')->type(LocalType::class, [])->domain('example.com')->create()); - - $response->assertOk(); - - $this->assertDatabaseHas('mailgateways', [ - 'domain' => 'example.com', - 'name' => 'lala', - 'type' => json_encode([ - 'cls' => LocalType::class, - 'params' => [], - ]), - ]); - } - - public function testItCanStoreAMailmanGateway(): void - { - $typeParams = ['url' => 'https://example.com', 'user' => 'user', 'password' => 'secret', 'owner' => 'owner@example.com']; - $this->stubIo(MailmanType::class, function ($mock) use ($typeParams) { - Phake::when($mock)->setParams($typeParams)->thenReturn($mock); - Phake::when($mock)->works()->thenReturn(true); - Phake::when($mock)->setOwner('owner@example.com')->thenReturn($mock); - }); - $this->postJson('/api/mailgateway', MailgatewayRequestFactory::new()->type(MailmanType::class, MailmanTypeRequest::new()->create($typeParams))->create()); - - $this->assertDatabaseHas('mailgateways', [ - 'type' => json_encode([ - 'cls' => MailmanType::class, - 'params' => $typeParams, - ]), - ]); - } - - public function testItThrowsErrorWhenMailmanConnectionFailed(): void - { - $typeParams = ['url' => 'https://example.com', 'user' => 'user', 'password' => 'secret', 'owner' => 'owner@example.com']; - $this->stubIo(MailmanType::class, function ($mock) use ($typeParams) { - Phake::when($mock)->setParams($typeParams)->thenReturn($mock); - Phake::when($mock)->works()->thenReturn(false); - Phake::when($mock)->setOwner('owner@example.com')->thenReturn($mock); - }); - $this->postJson('/api/mailgateway', MailgatewayRequestFactory::new()->type(MailmanType::class, MailmanTypeRequest::new()->create($typeParams))->create()) - ->assertJsonValidationErrors('connection'); - } - - public function testItValidatesCustomFields(): void - { - $typeParams = ['url' => 'https://example.com', 'user' => '', 'password' => 'secret', 'owner' => 'aaaa']; - $this->stubIo(MailmanType::class, function ($mock) use ($typeParams) { - Phake::when($mock)->setParams($typeParams)->thenReturn($mock); - Phake::when($mock)->works()->thenReturn(false); - }); - $this->postJson('/api/mailgateway', MailgatewayRequestFactory::new()->type(MailmanType::class, MailmanTypeRequest::new()->create($typeParams))->create()) - ->assertJsonValidationErrors([ - 'type.params.user' => 'Benutzer ist erforderlich.', - 'type.params.owner' => 'E-Mail-Adresse des Eigentümers muss eine gültige E-Mail-Adresse sein.', - ]); - } - - public function testItValidatesType(): void - { - $this->postJson('/api/mailgateway', MailgatewayRequestFactory::new()->missingType()->create()) - ->assertJsonValidationErrors('type.cls'); - } - - public function testItValidatesNameAndDomain(): void - { - $this->postJson('/api/mailgateway', MailgatewayRequestFactory::new()->withoutName()->withoutDomain()->create()) - ->assertJsonValidationErrors('domain') - ->assertJsonValidationErrors('name'); - } -} diff --git a/tests/Feature/Mailgateway/UpdateTest.php b/tests/Feature/Mailgateway/UpdateTest.php deleted file mode 100644 index 38257108..00000000 --- a/tests/Feature/Mailgateway/UpdateTest.php +++ /dev/null @@ -1,31 +0,0 @@ -login()->loginNami(); - } - - public function testItCanUpdateALocalGateway(): void - { - $mailgateway = Mailgateway::factory()->type(LocalType::class, [])->create(); - $response = $this->patchJson("/api/mailgateway/{$mailgateway->id}", MailgatewayRequestFactory::new()->name('lala')->type(LocalType::class, [])->domain('example.com')->create()); - - $response->assertOk(); - - $this->assertDatabaseCount('mailgateways', 1); - } -}