function PanelizerUserTest::testUserConfiguration in Panelizer 7.3
Test the user configuration functionality.
File
- tests/
panelizer.user.test, line 46 - Panelizer tests.
Class
- PanelizerUserTest
- Verifies Panelizer configuration options for user entities.
Code
function testUserConfiguration() {
// Load the users settings page.
$this
->drupalGet('admin/config/people/accounts');
$this
->assertResponse(200);
// Confirm that the appropriate fields are present.
$this
->assertFieldByName('panelizer[status]');
$this
->assertFieldByName('panelizer[help]');
foreach (array(
'page_manager',
'default',
) as $view_mode) {
$this
->assertFieldByName('panelizer[view modes][' . $view_mode . '][status]');
$this
->assertFieldByName('panelizer[view modes][' . $view_mode . '][default]');
$this
->assertFieldByName('panelizer[view modes][' . $view_mode . '][choice]');
}
// Submit the form to panelize the user entity.
$edit = array(
// Enable Panelzier.
'panelizer[status]' => TRUE,
'panelizer[view modes][page_manager][status]' => TRUE,
'panelizer[view modes][page_manager][default]' => TRUE,
);
$this
->drupalPost(NULL, $edit, t('Save configuration'));
$this
->assertResponse(200);
// Confirm the settings saved correctly.
$pm_links = array(
'!pm' => l('Page Manager', 'admin/structure/pages'),
'!panels' => l('Panels', 'admin/structure/panels'),
'!task_name' => 'user_view',
'!entity_type' => 'user',
);
$this
->assertText(strip_tags(t('Note: "!task_name" display must be enabled in !pm in order for the !entity_type full page display ("Full page override") to work correctly.', $pm_links)));
$this
->assertText(t('The configuration options have been saved.'));
// Verify the user can be panelized.
$this
->drupalGet('user/' . $this->admin_user->uid);
$this
->assertResponse(200);
$this
->assertLink('Customize display', 0, 'The "Customize display" link appears on the page');
$this
->assertLinkByHref('user/' . $this->admin_user->uid . '/panelizer', 0, 'A link to customize the user page display appears on the page');
// Check that the view mode has not been panelized yet.
$elements = $this
->xpath('//div[contains(@class,:class)]', array(
':class' => 'panelizer-view-mode',
));
$this
->assertEqual(count($elements), 0, 'The user object display is not panelized yet.');
$this
->assertText(t('Member for'));
// Enable the Page Manager handler for the user_view display.
variable_set('page_manager_user_view_disabled', FALSE);
drupal_flush_all_caches();
// Check that the view mode has now been panelized.
$this
->drupalGet('user/' . $this->admin_user->uid);
$this
->assertResponse(200);
$this
->assertLink('Customize display', 0, 'The "Customize display" link appears on the page');
$this
->assertLinkByHref('user/' . $this->admin_user->uid . '/panelizer', 0, 'A link to customize the user page display appears on the page');
$this
->assertNoText(t('Member for'));
// This won't be available because there's no default display for the user
// entity.
// $elements = $this->xpath('//div[contains(@class,:class)]', array(':class' => 'panelizer-view-mode'));
// $this->assertEqual(count($elements), 1, 'The user object display is now panelized.');
}