You are here

protected static function ApiTests::getEnv in Auth0 Single Sign On 8.2

Get all test suite environment variables.

Return value

array

Throws

\Auth0\SDK\Exception\ApiException

18 calls to ApiTests::getEnv()
BasicCrudTest::__construct in vendor/auth0/auth0-php/tests/API/BasicCrudTest.php
BasicCrudTest constructor. Sets up environment and domain value.
BlacklistsTest::testBlacklistAndGet in vendor/auth0/auth0-php/tests/API/Management/BlacklistsTest.php
ClientCredentialsTest::testOauthToken in vendor/auth0/auth0-php/tests/API/Authentication/ClientCredentialsTest.php
ClientGrantsTest::setUpBeforeClass in vendor/auth0/auth0-php/tests/API/Management/ClientGrantsTest.php
ClientsTest::testIntegrationCreateGetUpdateDelete in vendor/auth0/auth0-php/tests/API/Management/ClientsTest.php

... See full list

File

vendor/auth0/auth0-php/tests/API/ApiTests.php, line 33

Class

ApiTests
Class ApiTests. Extend to test API endpoints with a live or mock API.

Namespace

Auth0\Tests\API

Code

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;
}