public function BitbucketFormTest::testConfigureForm in Build Hooks 8.2
Same name and namespace in other branches
- 3.x modules/build_hooks_bitbucket/tests/src/Functional/BitbucketFormTest.php \Drupal\Tests\build_hooks_bitbucket\Functional\BitbucketFormTest::testConfigureForm()
Tests configuration form.
File
- modules/
build_hooks_bitbucket/ tests/ src/ Functional/ BitbucketFormTest.php, line 32
Class
- BitbucketFormTest
- Defines a test for the configuration form of the bitbucket pipelines plugin.
Namespace
Drupal\Tests\build_hooks_bitbucket\FunctionalCode
public function testConfigureForm() {
$this
->drupalLogin($this
->createUser([
'administer site configuration',
'access administration pages',
'access content',
'trigger deployments',
'manage frontend environments',
'access site reports',
]));
$this
->drupalGet('admin/config/build_hooks/frontend_environment/add/bitbucket');
$assert = $this
->assertSession();
$assert
->statusCodeEquals(200);
$random = mb_strtolower($this
->randomMachineName());
$values = [
'id' => $random,
'label' => $random,
'url' => 'http://example.com/' . $random,
'deployment_strategy' => 'manual',
'settings[repo][workspace]' => $random . '-workspace',
'settings[repo][slug]' => $random . '-slug',
'settings[ref][type]' => 'branch',
'settings[ref][name]' => $random . '-ref',
'settings[selector][type]' => 'pull-requests',
'settings[selector][name]' => $random . '-selector',
];
foreach ($values as $name => $value) {
$assert
->fieldExists($name)
->setValue($value);
}
$this
->submitForm([], 'Save');
/** @var \Drupal\build_hooks\Entity\FrontendEnvironmentInterface $environment */
$environment = \Drupal::entityTypeManager()
->getStorage('frontend_environment')
->load($random);
$this
->assertNotEmpty($environment);
$settings = $environment
->get('settings');
$this
->assertEquals($settings['selector']['type'], 'pull-requests');
$this
->assertEquals($settings['selector']['name'], $random . '-selector');
$this
->assertEquals($settings['ref']['type'], 'branch');
$this
->assertEquals($settings['ref']['name'], $random . '-ref');
$this
->assertEquals($settings['repo']['workspace'], $random . '-workspace');
$this
->assertEquals($settings['repo']['slug'], $random . '-slug');
}