protected function PanelizerUserFunctionalTest::setUp in Panelizer 8.5
Same name and namespace in other branches
- 8.4 tests/src/Functional/PanelizerUserFunctionalTest.php \Drupal\Tests\panelizer\Functional\PanelizerUserFunctionalTest::setUp()
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ PanelizerUserFunctionalTest.php, line 44
Class
- PanelizerUserFunctionalTest
- Basic functional tests of using Panelizer with user entities.
Namespace
Drupal\Tests\panelizer\FunctionalCode
protected function setUp() {
parent::setUp();
$this
->drupalPlaceBlock('local_tasks_block');
BlockContentType::create([
'id' => 'test',
'label' => 'Test',
])
->save();
block_content_add_body_field('test');
$this->blockContent = BlockContent::create([
'type' => 'test',
'info' => $this
->randomString(),
'body' => $this
->getRandomGenerator()
->sentences(5),
'uuid' => 'test',
]);
$this->blockContent
->save();
// Create the admin user.
$user = $this
->drupalCreateUser([
// Required for Panelizer.
'administer panelizer',
'access panels in-place editing',
// Allow managing user entities.
'administer users',
// Allow managing user entity settings.
'administer account settings',
// View access to user profiles.
'access user profiles',
// Allow managing the user entity fields and display settings.
'administer user display',
'administer user fields',
'configure any layout',
]);
$this
->drupalLogin($user);
/** @var \Drupal\panelizer\Panelizer $panelizer */
$panelizer = $this->container
->get('panelizer');
$panelizer
->setPanelizerSettings('user', 'user', 'full', [
'enable' => TRUE,
'allow' => TRUE,
'custom' => TRUE,
'default' => 'default',
]);
$panelizer
->setDisplayStaticContexts('default', 'user', 'user', 'full', [
'value' => [
'type' => 'any',
'label' => 'Lucky number',
'description' => 'Always loop to this number and great things will happen',
'value' => 42,
],
'letter' => [
'type' => 'string',
'label' => 'Letter of the day',
'description' => 'Straight from the NATO phonetic alphabet',
'value' => 'Juliet',
],
]);
$default = $panelizer
->getDefaultPanelsDisplay('default', 'user', 'user', 'full');
$default
->addBlock([
'id' => 'context_block',
'region' => 'content',
'weight' => 0,
]);
$panelizer
->setDefaultPanelsDisplay('default', 'user', 'user', 'full', $default);
// Clone the default display and save it with a new identifier so we can
// test migration of non-default layouts.
$alpha = clone $default;
$configuration = $alpha
->getConfiguration();
$configuration['label'] = 'Alpha';
$configuration['static_context'] = [
'value' => [
'type' => 'any',
'label' => 'Lucky number',
'description' => '100 with an off-by-one error',
'value' => 99,
],
'letter' => [
'type' => 'string',
'label' => 'Letter of the day',
'description' => 'The coolest letter in existence',
'value' => 'X-ray',
],
];
$alpha
->setConfiguration($configuration)
->addBlock([
'id' => 'system_powered_by_block',
'region' => 'content',
'weight' => 0,
]);
$alpha
->addBlock([
'id' => 'block_content:' . $this->blockContent
->uuid(),
'label' => $this->blockContent
->label(),
'region' => 'content',
'weight' => 1,
]);
$alpha
->addBlock([
'id' => 'context_block',
'region' => 'content',
'weight' => 2,
]);
$panelizer
->setDefaultPanelsDisplay('alpha', 'user', 'user', 'full', $alpha);
// Reload all caches.
$this
->rebuildAll();
}