permissions.test in Webform 6.2
File
tests/permissions.test
View source
<?php
include_once dirname(__FILE__) . '/webform.test';
class WebformPermissionsTestCase extends WebformTestCase {
public static function getInfo() {
return array(
'name' => t('Webform permissions'),
'description' => t('Create webforms and check editing and access permissions.'),
'group' => t('Webform'),
);
}
function setUp() {
parent::setUp();
}
function tearDown() {
parent::tearDown();
}
function testWebformSubmitAccess() {
$this
->webformReset();
$node = $this
->testWebformForm();
$node->webform['roles'] = array(
2,
);
node_save($node);
$this
->drupalLogin($this->webform_users['userAccess']);
$this
->drupalGet('node/' . $node->nid);
$this
->assertText($node->body, t('Webform node created and accessible to authenticated users at !url', array(
'!url' => 'node/' . $node->nid,
)), t('Webform'));
$this
->drupalPost(NULL, array(), 'Submit');
$this
->assertText($node->webform['confirmation'], t('Confirmation message "@confirmation" received.', array(
'@confirmation' => $node->webform['confirmation'],
)), t('Webform'));
$this
->drupalLogout();
$this
->drupalGet('node/' . $node->nid);
$this
->assertText(t(' to view this form.', array(
'!login' => url('user/login'),
'!register' => url('user/register'),
)), t('Anonymous user is not allowed to submit form.'), t('Webform'));
$this
->drupalLogout();
}
}