public function RolesTestMocked::testThatAddUsersRequestIsFormattedProperly in Auth0 Single Sign On 8.2
Test an add role user call.
Return value
void
Throws
\Exception Should not be thrown in this test.
File
- vendor/
auth0/ auth0-php/ tests/ API/ Management/ RolesMockedTest.php, line 609
Class
- RolesTestMocked
- Class RolesTestMocked.
Namespace
Auth0\Tests\API\ManagementCode
public function testThatAddUsersRequestIsFormattedProperly() {
$api = new MockManagementApi([
new Response(200, self::$headers),
]);
$api
->call()
->roles()
->addUsers('__test_role_id__', [
'strategy|1234567890',
'strategy|0987654321',
]);
$this
->assertEquals('POST', $api
->getHistoryMethod());
$this
->assertEquals('https://api.test.local/api/v2/roles/__test_role_id__/users', $api
->getHistoryUrl());
$headers = $api
->getHistoryHeaders();
$this
->assertEquals('Bearer __api_token__', $headers['Authorization'][0]);
$this
->assertEquals('application/json', $headers['Content-Type'][0]);
$this
->assertEquals(self::$expectedTelemetry, $headers['Auth0-Client'][0]);
$body = $api
->getHistoryBody();
$this
->assertArrayHasKey('users', $body);
$this
->assertCount(2, $body['users']);
$this
->assertContains('strategy|1234567890', $body['users']);
$this
->assertContains('strategy|0987654321', $body['users']);
}