MockIntegrationToggleKernelTest.php in Apigee Edge 8
File
tests/src/Kernel/MockIntegrationToggleKernelTest.php
View source
<?php
namespace Drupal\Tests\apigee_edge\Kernel;
use Apigee\MockClient\GuzzleHttp\MockHandler;
use Drupal\KernelTests\KernelTestBase;
use GuzzleHttp\HandlerStack;
class MockIntegrationToggleKernelTest extends KernelTestBase {
protected static $mock_api_client_ready = TRUE;
protected static $modules = [
'user',
'system',
'key',
'file',
'entity',
'syslog',
'apigee_edge',
];
protected function setUp() {
parent::setUp();
$this
->installConfig([
'apigee_edge',
]);
$this
->installEntitySchema('user');
$this
->installSchema('system', [
'sequences',
]);
$this
->installSchema('user', [
'users_data',
]);
}
public function testIntegrationToggleOff() {
$integration_enabled = getenv('APIGEE_INTEGRATION_ENABLE');
putenv('APIGEE_INTEGRATION_ENABLE=0');
$this
->enableModules([
'apigee_mock_api_client',
]);
$handler = $this->container
->get('apigee_mock_api_client.mock_http_client_factory')
->fromOptions([])
->getConfig('handler');
self::assertInstanceOf(MockHandler::class, $handler);
putenv('APIGEE_INTEGRATION_ENABLE=' . $integration_enabled ? 1 : 0);
}
public function testIntegrationToggleOn() {
$integration_enabled = getenv('APIGEE_INTEGRATION_ENABLE');
putenv('APIGEE_INTEGRATION_ENABLE=1');
$this
->enableModules([
'apigee_mock_api_client',
]);
$handler = $this->container
->get('apigee_mock_api_client.mock_http_client_factory')
->fromOptions([])
->getConfig('handler');
self::assertInstanceOf(HandlerStack::class, $handler);
putenv('APIGEE_INTEGRATION_ENABLE=' . $integration_enabled ? 1 : 0);
}
}