View source
<?php
namespace Drupal\Tests\build_hooks\Kernel;
use Drupal\build_hooks\TriggerInterface;
use GuzzleHttp\Psr7\Response;
class BuildTriggerTest extends BuildHooksKernelTestBase {
public function testPreventBuildViaPlugin() {
$this
->assertFrontendEnvironmentBuildHook('build_hooks_test', TriggerInterface::DEPLOYMENT_STRATEGY_ENTITYSAVE, NULL, [
'whiz' => 'no deploy for you',
]);
}
public function testPreventBuildViaModule() {
$this
->assertFrontendEnvironmentBuildHook('build_hooks_test', TriggerInterface::DEPLOYMENT_STRATEGY_ENTITYSAVE, NULL, [
'whiz' => 'no deploy for you module',
]);
}
public function testAccessToDeployContents() {
$this
->assertFrontendEnvironmentBuildHook('build_hooks_test', TriggerInterface::DEPLOYMENT_STRATEGY_ENTITYSAVE, NULL, [
'whiz' => 'whang',
], NULL, "can't let you do that dave");
}
public function testGenericFrontendEnvironment(string $deployment_strategy = TriggerInterface::DEPLOYMENT_STRATEGY_MANUAL) {
$this
->assertFrontendEnvironmentBuildHook('generic', $deployment_strategy, 'http://example.com?foo=bar', [
'build_hook_url' => 'http://example.com?foo=bar',
], new Response(201, [], 'Hello, Generic'));
}
public function providerFrontendEnvironment() {
return [
'Entity save' => [
TriggerInterface::DEPLOYMENT_STRATEGY_ENTITYSAVE,
],
'Cron' => [
TriggerInterface::DEPLOYMENT_STRATEGY_CRON,
],
'Manual' => [
TriggerInterface::DEPLOYMENT_STRATEGY_MANUAL,
],
];
}
}