View source
<?php
namespace Drupal\Tests\panelizer\Functional;
use Drupal\Tests\BrowserTestBase;
class PanelizerUserFunctionalTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'field',
'field_ui',
'user',
'layout_discovery',
'ctools',
'panels',
'panels_ipe',
'panelizer',
'panelizer_test',
];
protected function setUp() {
parent::setUp();
$user = $this
->drupalCreateUser([
'administer panelizer',
'access panels in-place editing',
'administer users',
'administer account settings',
'access user profiles',
'administer user display',
'administer user fields',
]);
$this
->drupalLogin($user);
$this
->drupalGet('admin/config/people/accounts/display');
$this
->assertResponse(200);
$edit = [
'panelizer[enable]' => TRUE,
'panelizer[custom]' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, t('Save'));
$this
->assertResponse(200);
$this
->rebuildAll();
}
public function testPanelizerDefault() {
$panelizer = \Drupal::service('panelizer');
$displays = $panelizer
->getDefaultPanelsDisplays('user', 'user', 'default');
$display = $displays['default'];
$display
->addBlock([
'id' => 'panelizer_test',
'label' => 'Panelizer test',
'provider' => 'block_content',
'region' => 'content',
]);
$panelizer
->setDefaultPanelsDisplay('default', 'user', 'user', 'default', $display);
$account = $this
->drupalCreateUser();
$out = $this
->drupalGet('user/' . $account
->id());
$this
->assertResponse(200);
$this
->verbose($out);
$elements = $this
->xpath('//*[@id="panels-ipe-content"]');
if (is_array($elements)) {
$this
->assertIdentical(count($elements), 1);
}
else {
$this
->fail('Could not parse page content.');
}
$this
->assertText('Panelizer test');
$this
->assertText('Abracadabra');
}
}