Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Reseller/UsersTest.php
Show All 26 Lines | class UsersTest extends TestCase | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function tearDown(): void | public function tearDown(): void | ||||
{ | { | ||||
$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'); | ||||
\App\SharedFolderAlias::truncate(); | |||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test user deleting (DELETE /api/v4/users/<id>) | * Test user deleting (DELETE /api/v4/users/<id>) | ||||
*/ | */ | ||||
public function testDestroy(): void | public function testDestroy(): void | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | public function testIndex(): void | ||||
$response = $this->actingAs($reseller2)->get("api/v4/users?owner={$user->id}"); | $response = $this->actingAs($reseller2)->get("api/v4/users?owner={$user->id}"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertSame(0, $json['count']); | $this->assertSame(0, $json['count']); | ||||
$this->assertSame([], $json['list']); | $this->assertSame([], $json['list']); | ||||
// Search by shared folder email | |||||
$response = $this->actingAs($reseller1)->get("api/v4/users?search=folder-event@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']); | |||||
// Search by shared folder alias | |||||
$folder = $this->getTestSharedFolder('folder-event@kolab.org'); | |||||
$folder->setAliases(['folder-alias@kolab.org']); | |||||
$response = $this->actingAs($reseller1)->get("api/v4/users?search=folder-alias@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']); | |||||
// Create a domain with some users in the Sample Tenant so we have anything to search for | // Create a domain with some users in the Sample Tenant so we have anything to search for | ||||
$domain = $this->getTestDomain('testsearch.com', ['type' => \App\Domain::TYPE_EXTERNAL]); | $domain = $this->getTestDomain('testsearch.com', ['type' => \App\Domain::TYPE_EXTERNAL]); | ||||
$domain->tenant_id = $reseller2->tenant_id; | $domain->tenant_id = $reseller2->tenant_id; | ||||
$domain->save(); | $domain->save(); | ||||
$user = $this->getTestUser('test@testsearch.com'); | $user = $this->getTestUser('test@testsearch.com'); | ||||
$user->tenant_id = $reseller2->tenant_id; | $user->tenant_id = $reseller2->tenant_id; | ||||
$user->save(); | $user->save(); | ||||
$plan = \App\Plan::where('title', 'group')->first(); | $plan = \App\Plan::where('title', 'group')->first(); | ||||
▲ Show 20 Lines • Show All 376 Lines • Show Last 20 Lines |