ApiTests.php in Auth0 Single Sign On 8.2
File
vendor/auth0/auth0-php/tests/API/ApiTests.php
View source
<?php
namespace Auth0\Tests\API;
use Auth0\SDK\API\Authentication;
use Auth0\Tests\Traits\ErrorHelpers;
use Auth0\SDK\API\Management;
use josegonzalez\Dotenv\Loader;
class ApiTests extends \PHPUnit_Framework_TestCase {
use ErrorHelpers;
protected static $env = [];
protected static function getEnv() {
if (self::$env) {
return self::$env;
}
$env_path = '.env';
if (file_exists($env_path)) {
$loader = new Loader($env_path);
$loader
->parse()
->putenv(true);
}
$env = [
'DOMAIN' => getenv('DOMAIN'),
'APP_CLIENT_ID' => getenv('APP_CLIENT_ID'),
'APP_CLIENT_SECRET' => getenv('APP_CLIENT_SECRET'),
'API_TOKEN' => getenv('API_TOKEN'),
];
if (!$env['API_TOKEN'] && $env['APP_CLIENT_SECRET']) {
$auth_api = new Authentication($env['DOMAIN'], $env['APP_CLIENT_ID'], $env['APP_CLIENT_SECRET']);
$response = $auth_api
->client_credentials([
'audience' => 'https://' . $env['DOMAIN'] . '/api/v2/',
]);
$env['API_TOKEN'] = $response['access_token'];
}
self::$env = $env;
return self::$env;
}
}
Classes
Name |
Description |
ApiTests |
Class ApiTests.
Extend to test API endpoints with a live or mock API. |