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,7 +142,6 @@ 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();
|
||||||
|
|
||||||
@ -155,7 +154,6 @@ class UserTest extends TestCase
|
|||||||
'ids' => [$user_id],
|
'ids' => [$user_id],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-TOKEN' => $company_token->token,
|
'X-API-TOKEN' => $company_token->token,
|
||||||
@ -166,6 +164,42 @@ class UserTest extends TestCase
|
|||||||
|
|
||||||
$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