public function PanelizerNodeTranslationsTest::testPanelizerDefault in Panelizer 8.4
Same name and namespace in other branches
- 8.5 tests/src/Functional/PanelizerNodeTranslationsTest.php \Drupal\Tests\panelizer\Functional\PanelizerNodeTranslationsTest::testPanelizerDefault()
Tests rendering a node with Panelizer default.
File
- tests/
src/ Functional/ PanelizerNodeTranslationsTest.php, line 152
Class
- PanelizerNodeTranslationsTest
- Test node translation handling in Panelizer.
Namespace
Drupal\Tests\panelizer\FunctionalCode
public function testPanelizerDefault() {
$this
->panelize($this->bundle, NULL, [
'panelizer[custom]' => TRUE,
]);
/** @var \Drupal\panelizer\PanelizerInterface $panelizer */
$panelizer = $this->container
->get('panelizer');
$displays = $panelizer
->getDefaultPanelsDisplays($this->entityTypeId, $this->bundle, 'default');
$display = $displays['default'];
$display
->addBlock([
'id' => 'panelizer_test',
'label' => 'Panelizer test',
'provider' => 'block_content',
'region' => 'content',
]);
$panelizer
->setDefaultPanelsDisplay('default', $this->entityTypeId, $this->bundle, 'default', $display);
// Create a node, and check that the IPE is visible on it.
$node = $this
->drupalCreateNode([
'type' => $this->bundle,
'langcode' => [
[
'value' => 'en',
],
],
]);
$out = $this
->drupalGet('node/' . $node
->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.');
}
// Check that the block we added is visible.
$this
->assertText('Panelizer test');
$this
->assertText('Abracadabra');
// Load the translation page.
$this
->clickLink('Translate');
$this
->assertText('English (Original language)');
$this
->assertText('Published');
$this
->assertText('Not translated');
}