Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Admin/UsersTest.php
Show All 14 Lines | class UsersTest extends TestCase | ||||
public function setUp(): void | public function setUp(): void | ||||
{ | { | ||||
parent::setUp(); | parent::setUp(); | ||||
self::useAdminUrl(); | self::useAdminUrl(); | ||||
$this->deleteTestUser('UsersControllerTest1@userscontroller.com'); | $this->deleteTestUser('UsersControllerTest1@userscontroller.com'); | ||||
$this->deleteTestUser('test@testsearch.com'); | $this->deleteTestUser('test@testsearch.com'); | ||||
$this->deleteTestDomain('testsearch.com'); | $this->deleteTestDomain('testsearch.com'); | ||||
$this->deleteTestGroup('group-test@kolab.org'); | |||||
$jack = $this->getTestUser('jack@kolab.org'); | $jack = $this->getTestUser('jack@kolab.org'); | ||||
$jack->setSetting('external_email', null); | $jack->setSetting('external_email', null); | ||||
} | } | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
Show All 11 Lines | class UsersTest extends TestCase | ||||
/** | /** | ||||
* Test users searching (/api/v4/users) | * Test users searching (/api/v4/users) | ||||
*/ | */ | ||||
public function testIndex(): void | public function testIndex(): void | ||||
{ | { | ||||
$user = $this->getTestUser('john@kolab.org'); | $user = $this->getTestUser('john@kolab.org'); | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
$group = $this->getTestGroup('group-test@kolab.org'); | |||||
$group->assignToWallet($user->wallets->first()); | |||||
// Non-admin user | // Non-admin user | ||||
$response = $this->actingAs($user)->get("api/v4/users"); | $response = $this->actingAs($user)->get("api/v4/users"); | ||||
$response->assertStatus(403); | $response->assertStatus(403); | ||||
// Search with no search criteria | // Search with no search criteria | ||||
$response = $this->actingAs($admin)->get("api/v4/users"); | $response = $this->actingAs($admin)->get("api/v4/users"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | public function testIndex(): void | ||||
$response = $this->actingAs($admin)->get("api/v4/users?owner={$ned->id}"); | $response = $this->actingAs($admin)->get("api/v4/users?owner={$ned->id}"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertSame(0, $json['count']); | $this->assertSame(0, $json['count']); | ||||
$this->assertCount(0, $json['list']); | $this->assertCount(0, $json['list']); | ||||
// Search by distribution list email | |||||
$response = $this->actingAs($admin)->get("api/v4/users?search=group-test@kolab.org"); | |||||
$response->assertStatus(200); | |||||
$json = $response->json(); | |||||
$this->assertSame(1, $json['count']); | |||||
$this->assertCount(1, $json['list']); | |||||
$this->assertSame($user->id, $json['list'][0]['id']); | |||||
$this->assertSame($user->email, $json['list'][0]['email']); | |||||
// Deleted users/domains | // Deleted users/domains | ||||
$domain = $this->getTestDomain('testsearch.com', ['type' => \App\Domain::TYPE_EXTERNAL]); | $domain = $this->getTestDomain('testsearch.com', ['type' => \App\Domain::TYPE_EXTERNAL]); | ||||
$user = $this->getTestUser('test@testsearch.com'); | $user = $this->getTestUser('test@testsearch.com'); | ||||
$plan = \App\Plan::where('title', 'group')->first(); | $plan = \App\Plan::where('title', 'group')->first(); | ||||
$user->assignPlan($plan, $domain); | $user->assignPlan($plan, $domain); | ||||
$user->setAliases(['alias@testsearch.com']); | $user->setAliases(['alias@testsearch.com']); | ||||
Queue::fake(); | Queue::fake(); | ||||
$user->delete(); | $user->delete(); | ||||
▲ Show 20 Lines • Show All 180 Lines • Show Last 20 Lines |