opigno_simple_ui.og.test in Opigno 7.0
Check OG overrides.
File
modules/opigno_simple_ui/tests/opigno_simple_ui.og.testView source
<?php
/**
* @file
* Check OG overrides.
*/
class OpignoSimpleUIOGTest extends AbstractOpignoSimpleUITest {
public function getInfo() {
return array(
'name' => 'Opigno Simple OG UI',
'description' => 'Ensure that OG overrides work correctly.',
'group' => 'Opigno Simple UI',
);
}
public function setUp() {
parent::setUp('opigno_simple_ui', 'og', 'og_ui', 'views', 'views_ui');
$this->admin = $this
->drupalCreateUser(array_keys(module_invoke_all('permission')));
$this->authenticated_user = $this
->drupalCreateUser(array(
'access content',
'administer nodes',
));
}
/**
* Simple UI overrides several URLs to more user-friendly, logical items.
* For example, an OG node will have a "Members" tab, and underneath that
* an "Add members" sub tab. However, the "Group" tab is removed.
*/
public function testOGNodeUrls() {
if ($this
->_checkDependency('og') || $this
->_checkDependency('og_ui')) {
$this
->drupalLogin($this->admin);
$this
->_prepareOGType();
$gid = $this
->_createOGNode();
// There should be no "Group" tab
$this
->assertNoLink('Group', 'Should be no "Group" tab.');
$this
->clickLink('Members');
$this
->assertText($this->admin->name);
$this
->clickLink('Add members');
$this
->assertText('Add a group member to');
// Hide membership state
$this
->assertNoFieldById('edit-og-add-user-state', '', 'Hide membership state. Defaults to active.');
// Hide membership type
$this
->assertNoFieldById('edit-og-add-user-membership-type', '', 'Hide membership type. Defaults to default anyway.');
// Possibility to select role directly
$this
->assertFieldById('edit-og-role-3', '', 'Roles checkboxes exist.');
// Add user to group and grant admin rights (role #3 by default)
$edit = array(
'og_add_user' => $this->authenticated_user->name,
"og_role[3]" => 3,
);
$this
->drupalPost($this
->getURL(), $edit, 'Add users');
$this
->clickLink('Members');
$this
->assertText($this->authenticated_user->name, 'Found user name. Was added to group.');
$matches = array();
$this
->assertEqual(preg_match_all('/<li[\\s="a-zA-Z0-9]*>administrator member<\\/li>/', $this
->drupalGetContent(), $matches), 1, 'Should have administrator rights (find text 1x).');
}
}
/**
* Create an OG node type and an OG content node type.
*/
protected function _prepareOGType() {
$this
->drupalGet('admin/structure/types/add');
$edit = array(
'name' => 'OG',
'type' => 'og',
'og_group_type' => 'group',
);
$this
->drupalPost($this
->getURL(), $edit, 'Save content type');
$this
->drupalGet('admin/structure/types/add');
$edit = array(
'name' => 'OG content',
'type' => 'og_content',
'og_group_content_type' => 'og_content',
);
$this
->drupalPost($this
->getURL(), $edit, 'Save content type');
}
/**
* Create an OG node
*/
protected function _createOGNode() {
$this
->drupalGet('node/add/og');
// Check that Group field is on by default and hiddent
$this
->assertNoFieldById('edit-group-group-und', '', 'Group checkbox is hidden.');
$edit = array(
'title' => $this
->randomName(8),
'body[' . LANGUAGE_NONE . '][0][value]' => $this
->randomName(8),
);
$this
->drupalPost($this
->getURL(), $edit, 'Save');
$matches = array();
preg_match('/node\\/([0-9]+)$/', $this
->getURL(), $matches);
$node = node_load($matches[1]);
return $node->group_group[LANGUAGE_NONE][0]['value'];
}
/**
* Create an OG contentg node
*/
protected function _createOGContentNode($gid = NULL) {
$this
->drupalGet('node/add/og-content', isset($gid) ? array(
'query' => array(
'gids_node[]' => $gid,
),
) : array());
// Check that the audience field is hidden
$this
->assertTrue(preg_match('/div (class="[\\sa-z0-9\\-\\_]*element-hidden[\\sa-z0-9\\-\\_]*"(\\s)?)?id="edit-group-audience"((\\s)?class="[\\sa-z0-9\\-\\_]*element-hidden[\\sa-z0-9\\-\\_]*")?/', $this
->drupalGetContent()), 'Group audience select is hidden');
$edit = array(
'title' => $this
->randomName(8),
);
$this
->drupalPost($this
->getURL(), $edit, 'Save');
}
}
Classes
Name | Description |
---|---|
OpignoSimpleUIOGTest | @file Check OG overrides. |