GithubBuildHooksTest.php in Build Hooks 3.x
File
modules/build_hooks_github/tests/src/Kernel/GithubBuildHooksTest.php
View source
<?php
namespace Drupal\Tests\build_hooks_github\Kernel;
use Drupal\build_hooks\TriggerInterface;
use Drupal\Tests\build_hooks\Kernel\BuildHooksKernelTestBase;
use GuzzleHttp\Psr7\Response;
class GithubBuildHooksTest extends BuildHooksKernelTestBase {
protected static $modules = [
'build_hooks',
'build_hooks_github',
'views',
'build_hooks_test',
'system',
'user',
'entity_test',
'dynamic_entity_reference',
];
protected $history = [];
protected $mockClient;
protected function setUp() : void {
parent::setUp();
$this
->installConfig('build_hooks_github');
}
public function testGithubFrontendEnvironment(string $deployment_strategy = TriggerInterface::DEPLOYMENT_STRATEGY_ENTITYSAVE) {
$random = $this
->getRandomGenerator()
->name();
$this
->assertFrontendEnvironmentBuildHook('github', $deployment_strategy, 'https://api.github.com/repos/' . $random . '-owner/' . $random . '-repo/actions/workflows/' . $random . '-workflow_id/dispatches', [
'build_hook_url' => 'https://api.github.com/repos/' . $random . '-owner/' . $random . '-repo/actions/workflows/' . $random . '-workflow_id/dispatches',
'branch' => 'branch',
], new Response(201, [], 'Hello, Github'));
}
public function providerFrontendEnvironment() {
return [
'Entity save' => [],
'Cron' => [
TriggerInterface::DEPLOYMENT_STRATEGY_CRON,
],
'Manual' => [
TriggerInterface::DEPLOYMENT_STRATEGY_MANUAL,
],
];
}
}