| 1 |
|
<?php |
| 2 |
|
// $Id$ |
| 3 |
|
|
| 4 |
|
/** |
| 5 |
|
* @file |
| 6 |
|
* Test file for nodewords module. |
| 7 |
|
*/ |
| 8 |
|
|
| 9 |
|
/** |
| 10 |
|
* Nodewords Test Case implementation. |
| 11 |
|
*/ |
| 12 |
|
class NodewordsTestCase extends DrupalWebTestCase { |
| 13 |
|
|
| 14 |
|
public static function getInfo() { |
| 15 |
|
return array( |
| 16 |
|
'name' => 'Nodewords test', |
| 17 |
|
'description' => 'Test nodewords functionality.', |
| 18 |
|
'group' => 'nodewords' |
| 19 |
|
); |
| 20 |
|
} |
| 21 |
|
|
| 22 |
|
function setUp() { |
| 23 |
|
// Enable minimum required modules. |
| 24 |
|
parent::setUp('nodewords', 'nodewords_basic'); |
| 25 |
|
} |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
/** |
| 29 |
|
* Verify that user without "administer nodes" permission is able to edit node |
| 30 |
|
* meta tags (issue: http://drupal.org/node/588946). |
| 31 |
|
*/ |
| 32 |
|
function testNodePermissionFunctionality() { |
| 33 |
|
|
| 34 |
|
// Create an administrator user. |
| 35 |
|
$permissions = array( |
| 36 |
|
'administer content types', |
| 37 |
|
'administer meta tags', |
| 38 |
|
); |
| 39 |
|
$user = $this->drupalCreateUser($permissions); |
| 40 |
|
|
| 41 |
|
// Log in to Drupal using the administrator user. |
| 42 |
|
$this->drupalLogin($user); |
| 43 |
|
|
| 44 |
|
// Enable the tags KEYWORDS, DESCRIPTION and COPYRIGHT for editing. |
| 45 |
|
$options = array( |
| 46 |
|
'nodewords_edit[keywords]' => 1, |
| 47 |
|
'nodewords_edit[description]' => 1, |
| 48 |
|
'nodewords_edit[copyright]' => 1, |
| 49 |
|
); |
| 50 |
|
$this->drupalPost('admin/content/nodewords', $options, t('Save configuration')); |
| 51 |
|
|
| 52 |
|
// Check that page content type has been updated. |
| 53 |
|
$this->assertRaw(t('The configuration options have been saved.')); |
| 54 |
|
|
| 55 |
|
// Create an user with permission to create a page node, and to edit the |
| 56 |
|
// meta tags COPYRIGHT, and DESCRIPTION. |
| 57 |
|
$permissions = array( |
| 58 |
|
'create page content', |
| 59 |
|
'edit meta tag COPYRIGHT', |
| 60 |
|
'edit meta tag DESCRIPTION', |
| 61 |
|
); |
| 62 |
|
|
| 63 |
|
$user = $this->drupalCreateUser($permissions); |
| 64 |
|
|
| 65 |
|
// Log in to Drupal using the previously created user. |
| 66 |
|
$this->drupalLogin($user); |
| 67 |
|
|
| 68 |
|
// Try to create a page node. |
| 69 |
|
$this->drupalGet('node/add/page'); |
| 70 |
|
$this->assertField('nodewords[copyright][value]', t('Copyright meta tag field found.')); |
| 71 |
|
$this->assertField('nodewords[description][value]', t('Description meta tag field found.')); |
| 72 |
|
$this->assertNoField('nodewords[keywords][value]', t('Keywords meta tag field not found.')); |
| 73 |
|
} |
| 74 |
|
} |