Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/DomainsTest.php
Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | class DomainsTest extends TestCase | ||||
{ | { | ||||
// User with no domains | // User with no domains | ||||
$user = $this->getTestUser('test1@domainscontroller.com'); | $user = $this->getTestUser('test1@domainscontroller.com'); | ||||
$response = $this->actingAs($user)->get("api/v4/domains"); | $response = $this->actingAs($user)->get("api/v4/domains"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertSame([], $json); | $this->assertCount(4, $json); | ||||
$this->assertSame(0, $json['count']); | |||||
$this->assertSame(false, $json['hasMore']); | |||||
$this->assertSame("0 domains have been found.", $json['message']); | |||||
$this->assertSame([], $json['list']); | |||||
// User with custom domain(s) | // User with custom domain(s) | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$ned = $this->getTestUser('ned@kolab.org'); | $ned = $this->getTestUser('ned@kolab.org'); | ||||
$response = $this->actingAs($john)->get("api/v4/domains"); | $response = $this->actingAs($john)->get("api/v4/domains"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(1, $json); | $this->assertCount(4, $json); | ||||
$this->assertSame('kolab.org', $json[0]['namespace']); | $this->assertSame(1, $json['count']); | ||||
$this->assertSame(false, $json['hasMore']); | |||||
$this->assertSame("1 domains have been found.", $json['message']); | |||||
$this->assertCount(1, $json['list']); | |||||
$this->assertSame('kolab.org', $json['list'][0]['namespace']); | |||||
// Values below are tested by Unit tests | // Values below are tested by Unit tests | ||||
$this->assertArrayHasKey('isConfirmed', $json[0]); | $this->assertArrayHasKey('isConfirmed', $json['list'][0]); | ||||
$this->assertArrayHasKey('isDeleted', $json[0]); | $this->assertArrayHasKey('isDeleted', $json['list'][0]); | ||||
$this->assertArrayHasKey('isVerified', $json[0]); | $this->assertArrayHasKey('isVerified', $json['list'][0]); | ||||
$this->assertArrayHasKey('isSuspended', $json[0]); | $this->assertArrayHasKey('isSuspended', $json['list'][0]); | ||||
$this->assertArrayHasKey('isActive', $json[0]); | $this->assertArrayHasKey('isActive', $json['list'][0]); | ||||
$this->assertArrayHasKey('isLdapReady', $json[0]); | $this->assertArrayHasKey('isLdapReady', $json['list'][0]); | ||||
$response = $this->actingAs($ned)->get("api/v4/domains"); | $response = $this->actingAs($ned)->get("api/v4/domains"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(1, $json); | $this->assertCount(4, $json); | ||||
$this->assertSame('kolab.org', $json[0]['namespace']); | $this->assertCount(1, $json['list']); | ||||
$this->assertSame('kolab.org', $json['list'][0]['namespace']); | |||||
} | } | ||||
/** | /** | ||||
* Test domain config update (POST /api/v4/domains/<domain>/config) | * Test domain config update (POST /api/v4/domains/<domain>/config) | ||||
*/ | */ | ||||
public function testSetConfig(): void | public function testSetConfig(): void | ||||
{ | { | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
▲ Show 20 Lines • Show All 338 Lines • Show Last 20 Lines |