mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Tests for users
This commit is contained in:
parent
a847bdb0ed
commit
0f931fe1a8
@ -127,8 +127,7 @@ class UserFilters extends QueryFilters
|
|||||||
$user_array = $this->transformKeys(explode(',', $user_id));
|
$user_array = $this->transformKeys(explode(',', $user_id));
|
||||||
|
|
||||||
return $this->builder->where(function ($query) use ($user_array) {
|
return $this->builder->where(function ($query) use ($user_array) {
|
||||||
$query->whereNotIn('id', $user_array)
|
$query->whereNotIn('id', $user_array);
|
||||||
->where('account_id', auth()->user()->account_id);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,29 +142,63 @@ class UserTest extends TestCase
|
|||||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||||
])->get('/api/v1/users', $data);
|
])->get('/api/v1/users', $data);
|
||||||
|
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
$arr = $response->json();
|
$arr = $response->json();
|
||||||
|
|
||||||
$this->assertCount(2, $arr['data']);
|
$this->assertCount(2, $arr['data']);
|
||||||
|
|
||||||
//archive the user we just created:
|
//archive the user we just created:
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'action' => 'archive',
|
'action' => 'archive',
|
||||||
'ids' => [$user_id],
|
'ids' => [$user_id],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $company_token->token,
|
||||||
|
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||||
|
])->postJson('/api/v1/users/bulk', $data);
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response->assertStatus(200);
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
|
||||||
'X-API-TOKEN' => $company_token->token,
|
|
||||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
|
||||||
])->postJson('/api/v1/users/bulk', $data);
|
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$this->assertCount(1, $response->json()['data']);
|
||||||
|
|
||||||
$this->assertCount(1, $response->json()['data']);
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $company_token->token,
|
||||||
|
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||||
|
])->get("/api/v1/users?without={$company_token->user->hashed_id}");
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$this->assertCount(1, $response->json()['data']);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $company_token->token,
|
||||||
|
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||||
|
])->get("/api/v1/users?without={$company_token->user->hashed_id}&status=active");
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$this->assertCount(0, $response->json()['data']);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $company_token->token,
|
||||||
|
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||||
|
])->get("/api/v1/users?without={$company_token->user->hashed_id}&status=archived");
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$this->assertCount(1, $response->json()['data']);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $company_token->token,
|
||||||
|
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||||
|
])->get("/api/v1/users?without={$company_token->user->hashed_id}&status=deleted");
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$this->assertCount(0, $response->json()['data']);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user