1 path_pattern.test | PathPatternFunctionalTestCase::testConfigurationUserInterfaces() |
File
- core/
modules/ path/ tests/ path_pattern.test, line 716 - Functionality tests for automatic path generation.
Class
- PathPatternFunctionalTestCase
- Test basic Path automatic URL alias functionality.
Code
function testConfigurationUserInterfaces() {
// Test validation.
$edit = array();
$edit['max_length'] = 'abc';
$edit['max_component_length'] = 'abc';
$this->backdropPost('admin/config/urls/path/patterns/settings', $edit, 'Save configuration');
$placeholders = array(
'%name' => 'Maximum URL alias length',
);
$this->assertRaw(format_string('The value for %name must be numeric.', $placeholders));
$placeholders = array(
'%name' => 'Maximum component length',
);
$this->assertRaw(format_string('The value for %name must be numeric.', $placeholders));
$this->assertNoText('The configuration options have been saved.');
$edit['max_length'] = '0';
$edit['max_component_length'] = '0';
$this->backdropPost('admin/config/urls/path/patterns/settings', $edit, 'Save configuration');
$placeholders = array(
'%name' => 'Maximum URL alias length',
'%min' => 1,
);
$this->assertRaw(format_string('The value for %name must be greater than or equal to %min.', $placeholders));
$placeholders = array(
'%name' => 'Maximum component length',
'%min' => 1,
);
$this->assertRaw(format_string('The value for %name must be greater than or equal to %min.', $placeholders));
$this->assertNoText('The configuration options have been saved.');
$edit['max_length'] = '999';
$edit['max_component_length'] = '999';
$this->backdropPost('admin/config/urls/path/patterns/settings', $edit, 'Save configuration');
$placeholders = array(
'%name' => 'Maximum URL alias length',
'%max' => 255,
);
$this->assertRaw(format_string('The value for %name must be less than or equal to %max.', $placeholders));
$placeholders = array(
'%name' => 'Maximum component length',
'%max' => 255,
);
$this->assertRaw(format_string('The value for %name must be less than or equal to %max.', $placeholders));
$this->assertNoText('The configuration options have been saved.');
$edit['max_length'] = '50';
$edit['max_component_length'] = '50';
$this->backdropPost('admin/config/urls/path/patterns/settings', $edit, 'Save configuration');
$this->assertText('The configuration options have been saved.');
// To test alternate interfaces, we need more permissions.
$permissions = array(
'administer path patterns',
'administer content types',
'administer taxonomy',
'administer account settings',
);
$this->admin_user = $this->backdropCreateUser($permissions);
$this->backdropLogin($this->admin_user);
// Test alternate interfaces - node type configuration.
$this->backdropCreateContentType(array('type' => 'post', 'name' => 'Post'));
$edit = array('path_pattern' => 'post/[node:title]/foo');
$this->backdropPost('admin/structure/types/manage/post', $edit, 'Save content type');
// Check that the page URL alias pattern is on the pathauto form.
$this->backdropGet('admin/config/urls/path/patterns');
$this->assertFieldByName('node_post_pattern', 'post/[node:title]/foo', 'URL alias pattern set with node type settings appears on path config page.');
// Test alternate interfaces - vocab configuration.
$vocabulary = $this->addVocabulary();
$pattern = $vocabulary->machine_name . '/[term:name]/foo';
$edit = array('path_pattern' => $pattern);
$this->backdropPost('admin/structure/taxonomy/' . $vocabulary->machine_name . '/configure', $edit, 'Save vocabulary');
// Check that the page URL alias pattern is on the pathauto form.
$this->backdropGet('admin/config/urls/path/patterns');
$this->assertFieldByName('taxonomy_term_' . $vocabulary->machine_name . '_pattern', $pattern, 'URL alias pattern set with vocabulary settings appears on path config page.');
// Test alternate interfaces - user configuration.
$edit = array('path_pattern' => 'accounts/[user:name]/foo');
$this->backdropPost('admin/config/people/settings', $edit, 'Save configuration');
// Check that the page URL alias pattern is on the pathauto form.
$this->backdropGet('admin/config/urls/path/patterns');
$this->assertFieldByName('user_pattern', 'accounts/[user:name]/foo', 'URL alias pattern set with user account settings appears on path config page.');
}