function PanelizerExportablesTest::testExportablesAreConfigurable in Panelizer 7.3
Verify that the exported configuration can be edited.
File
- tests/
panelizer.exportables.test, line 44 - Test the exportables functionality for Panelizer.
Class
- PanelizerExportablesTest
- @file Test the exportables functionality for Panelizer.
Code
function testExportablesAreConfigurable() {
$perms = array(
// Standard node permissions.
'administer content types',
'access administration pages',
// Panelizer main "all the things" permission.
'administer panelizer',
);
$web_user = $this
->drupalCreateUser($perms);
$this
->drupalLogin($web_user);
// Load the Panelizer admin page for the 'page' content type.
$this
->drupalGet('admin/structure/types/manage/page/panelizer/page_manager');
$this
->assertResponse(200);
// The two defaults that were exported.
$defaults = array(
'node:page:with_storage' => 'Test (with Storage API)',
'node:page:without_storage' => 'Test (without Storage API)',
);
// Confirm the two exported displays are listed.
foreach ($defaults as $default => $label) {
$this
->assertText($default);
}
// Try loading the exported displays' configuration pages.
foreach ($defaults as $default => $label) {
// $default = urlencode($default);
$this
->drupalGet('admin/structure/types/manage/page/panelizer/page_manager/' . $default . '/settings');
$this
->assertResponse(200);
$this
->assertFieldByName('title', $label);
$this
->assertFieldByName('css_class', str_replace(':', '-', $default));
$this
->drupalGet('admin/structure/types/manage/page/panelizer/page_manager/' . $default . '/context');
$this
->assertResponse(200);
$this
->assertText(t('Built in context'));
$this
->drupalGet('admin/structure/types/manage/page/panelizer/page_manager/' . $default . '/access');
$this
->assertResponse(200);
$this
->assertText(t('No criteria selected, this test will pass.'));
$this
->drupalGet('admin/structure/types/manage/page/panelizer/page_manager/' . $default . '/layout');
$this
->assertResponse(200);
$this
->assertFieldByName('categories');
$this
->drupalGet('admin/structure/types/manage/page/panelizer/page_manager/' . $default . '/content');
$this
->assertResponse(200);
// Confirm the 'Add content' link is on the page.
$this
->assertLink(t('Add content'));
$ajax_path = 'panels/ajax/editor/select-content/panelizer:default:node:page.page_manager:' . $default . '/center';
// Need to pass the path through url() to get the correct syntax for the
// actual link.
$this
->assertLinkByHref(url($ajax_path));
// Load the AJAX path to see what it contains.
$json = $this
->drupalGetAJAX($ajax_path);
$this
->assertResponse(200);
// Examine the JSON response from the AJAX API.
$this
->verbose('<pre>' . print_r($json, TRUE) . '</pre>');
// $this->assertEqual(count($json), 2);
$this
->assertTrue(isset($json[0]['command']));
$this
->assertEqual($json[0]['command'], 'settings');
$this
->assertTrue(isset($json[0]['settings']));
$this
->assertTrue(isset($json[0]['merge']));
$this
->assertEqual($json[0]['merge'], 'TRUE');
$this
->assertTrue(isset($json[1]['command']));
// This is what should happen.
$this
->assertEqual($json[1]['command'], 'modal_display');
$this
->assertTrue(isset($json[1]['title']));
if (isset($json[1]['title'])) {
$this
->assertEqual($json[1]['title'], t('Add content to Center'));
}
$this
->assertTrue(isset($json[1]['output']));
// This is what should not happen.
$this
->assertNotEqual($json[1]['command'], 'alert');
$this
->assertFalse(isset($json[1]['text']));
if (isset($json[1]['text'])) {
$this
->assertNotEqual($json[1]['text'], t('You are not authorized to access this page.'), 'Access Denied error in the AJAX response.');
}
}
}