mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2026-11-11 02:41:33 +00:00
[Web] API: complete the OpenAPI docs, add route tests for json_api.php
This commit is contained in:
47 files changed
+18848
-7491
No files matched your search
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mailcow\Tests\Api\Domains;
|
||||
|
||||
use Mailcow\Tests\Api\ApiTestCase;
|
||||
|
||||
/** get/add/edit/delete domain/template */
|
||||
class DomainTemplateTest extends ApiTestCase
|
||||
{
|
||||
private const TEMPLATE = ['id' => 1, 'template' => 'Default', 'type' => 'domain', 'attributes' => ['max_num_aliases_for_domain' => 400]];
|
||||
|
||||
public function testAllTemplates(): void
|
||||
{
|
||||
$result = $this->get('get/domain/template/all', ['script' => [self::answer('mailbox', ['get', 'domain_templates'], [self::TEMPLATE])]]);
|
||||
|
||||
$this->assertSame([['get', 'domain_templates']], $result->callsTo('mailbox'));
|
||||
$this->assertSame([self::TEMPLATE], $result->json());
|
||||
}
|
||||
|
||||
public function testOneTemplate(): void
|
||||
{
|
||||
$result = $this->get('get/domain/template/1', ['script' => [self::answer('mailbox', ['get', 'domain_templates', '1'], self::TEMPLATE)]]);
|
||||
|
||||
$this->assertSame(self::TEMPLATE, $result->json());
|
||||
}
|
||||
|
||||
public function testUnknownTemplate(): void
|
||||
{
|
||||
$result = $this->get('get/domain/template/9', ['script' => [self::answer('mailbox', ['get', 'domain_templates'], false)]]);
|
||||
|
||||
$this->assertCalled($result, 'mailbox', ['get', 'domain_templates', '9']);
|
||||
$this->assertSame('{}', $result->body);
|
||||
}
|
||||
|
||||
public function testTemplateWithoutIdAsksForAll(): void
|
||||
{
|
||||
$result = $this->get('get/domain/template');
|
||||
|
||||
$this->assertSame([['get', 'domain_templates', null]], $result->callsTo('mailbox'));
|
||||
}
|
||||
|
||||
public function testAddTemplate(): void
|
||||
{
|
||||
$attr = ['template' => 'Small business', 'max_num_mboxes_for_domain' => 25, 'def_quota_for_mbox' => 2048, 'tags' => ['small']];
|
||||
|
||||
$result = $this->post('add/domain/template', $attr);
|
||||
|
||||
$this->assertSame([['add', 'domain_templates', $attr]], $result->callsTo('mailbox'));
|
||||
}
|
||||
|
||||
public function testEditTemplates(): void
|
||||
{
|
||||
$result = $this->post('edit/domain/template', ['items' => [2, 3], 'attr' => ['template' => 'Small business', 'active' => 1]]);
|
||||
|
||||
$this->assertCalled($result, 'mailbox', ['edit', 'domain_templates', ['ids' => [2, 3], 'template' => 'Small business', 'active' => 1]]);
|
||||
}
|
||||
|
||||
public function testDeleteTemplates(): void
|
||||
{
|
||||
$result = $this->post('delete/domain/template', [2, 3]);
|
||||
|
||||
$this->assertCalled($result, 'mailbox', ['delete', 'domain_templates', ['ids' => [2, 3]]]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user