View source
<?php
namespace Drupal\yamlform\Tests;
class YamlFormPathTest extends YamlFormTestBase {
protected static $modules = [
'system',
'block',
'node',
'user',
'path',
'yamlform',
];
public function testPaths() {
$yamlform = $this
->createYamlForm();
$this
->drupalGet('yamlform/' . $yamlform
->id());
$this
->assertResponse(200, 'Submit system path exists');
$this
->drupalGet('form/' . str_replace('_', '-', $yamlform
->id()));
$this
->assertResponse(200, 'Submit URL alias exists');
$this
->drupalGet('form/' . str_replace('_', '-', $yamlform
->id()) . '/confirmation');
$this
->assertResponse(200, 'Confirm URL alias exists');
$yamlform
->setSettings([
'page' => FALSE,
])
->save();
$this
->drupalGet('yamlform/' . $yamlform
->id());
$this
->assertResponse(403, 'Submit system path access denied');
$this
->drupalGet('form/' . str_replace('_', '-', $yamlform
->id()));
$this
->assertResponse(403, 'Submit URL alias access denied');
$this
->drupalLogin($this->adminFormUser);
$this
->drupalGet('yamlform/' . $yamlform
->id());
$this
->assertResponse(200, 'Submit system path access permitted');
$this
->drupalGet('form/' . str_replace('_', '-', $yamlform
->id()));
$this
->assertResponse(200, 'Submit URL alias access permitted');
$this
->drupalLogout();
$yamlform
->setSettings([
'page_submit_path' => 'page_submit_path',
'page_confirm_path' => 'page_confirm_path',
])
->save();
$this
->drupalGet('page_submit_path');
$this
->assertResponse(200, 'Submit system path access permitted');
$this
->drupalGet('page_confirm_path');
$this
->assertResponse(200, 'Submit URL alias access permitted');
$yamlform
->setSettings([])
->save();
$this
->drupalLogin($this->adminFormUser);
$this
->drupalPostForm('admin/structure/yamlform/settings', [
'page[default_page_base_path]' => 'base/path',
], t('Save configuration'));
$this
->drupalGet('base/path/' . str_replace('_', '-', $yamlform
->id()));
$this
->assertResponse(200, 'Submit URL alias with custom base path exists');
$this
->drupalGet('base/path/' . str_replace('_', '-', $yamlform
->id()) . '/confirmation');
$this
->assertResponse(200, 'Confirm URL alias with custom base path exists');
}
}