You are here

protected function PanelizerTestHelper::togglePanelizer in Panelizer 7.3

Helper function to quickly enable or disable Panelizer for an entity type.

Parameters

string $entity_type: The entity type to configure, defaults to 'node'.

string $bundle: The entity bundle to enable, defaults to 'page'.

string $view_mode: The entity view mode to be panelized; defaults to 'page_manager'.

boolean $status: Indicate whther the view mode is enabled or disabled; defaults to TRUE.

boolean $use_default: Whether to enable a default display; defaults to TRUE.

boolean $choice: Whether to enable a display choice may be made; defaults to TRUE.

8 calls to PanelizerTestHelper::togglePanelizer()
PanelizerExportablesTest::setUp in tests/panelizer.exportables.test
Sets up a Drupal site for running functional and integration tests.
PanelizerNodeContentTranslationTest::testContentTranslation in tests/panelizer.node_content_translation.test
Verify that when a node is translated the customized Panelizer display is cloned to the new node.
PanelizerNodeTest::testViewModeReassignment in tests/panelizer.node.test
Confirm that view mode reassignment works correctly.
PanelizerTermTest::testTermPanelizeIt in tests/panelizer.term.test
PanelizerTermTest::testTermPanelsDefault in tests/panelizer.term.test

... See full list

File

tests/panelizer.helper.test, line 39
Test integration for the panelizer module.

Class

PanelizerTestHelper
This will be extended by other tests to simplify them and make the code more reusable.

Code

protected function togglePanelizer($entity_type = 'node', $bundle = 'page', $view_mode = 'page_manager', $status = 1, $use_default = 1, $choice = 1) {
  variable_set('panelizer_defaults_' . $entity_type . '_' . $bundle, array(
    'status' => 1,
    'help' => '',
    'view modes' => array(
      $view_mode => array(
        'status' => $status,
        'substitute' => FALSE,
        'default' => $use_default,
        'choice' => $choice,
      ),
    ),
  ));

  // Update the handler's plugin definition. Because of the way Panelizer is
  // caching the handler objects, the entity node handler has already been
  // loaded and has already identified what bundles are configured for this
  // page execution. In order to work around that, so that
  // hook_entity_update() can be called, need to reload the handler and rejig
  // the plugin defintion.
  ctools_include('plugins');
  ctools_plugin_get_plugin_type_info(TRUE);
  $handler = panelizer_entity_plugin_get_handler($entity_type);
  $plugin = panelizer_get_entity_plugin($entity_type);
  $info = ctools_plugin_get_info('panelizer', 'entity');
  panelizer_entity_plugin_process($plugin, $info);
  $handler->plugin = $plugin;
  $this
    ->verbose(print_r($handler, TRUE));
  $this
    ->assertTrue($handler
    ->is_panelized($bundle), 'Entity bundle is panelized.');
  return $handler;
}