Skip to content
Snippets Groups Projects
Verified Commit ebd60674 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3376566 by kunal.sachdev, sakthi_dev, divya.sejekan, Nitin shrivastava,...

Issue #3376566 by kunal.sachdev, sakthi_dev, divya.sejekan, Nitin shrivastava, djsagar, smustgrave, nod_, longwave, quietone, catch: Display the page title, even if "0" in olivero

(cherry picked from commit 00432f54)
parent c13f63ce
No related branches found
No related tags found
6 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...
Pipeline #120471 canceled
<?php
declare(strict_types=1);
namespace Drupal\Tests\system\Functional\Theme;
use Drupal\Tests\node\Functional\NodeTestBase;
/**
* Tests node title for a theme.
*/
abstract class NodeTitleTestBase extends NodeTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = ['block'];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->drupalPlaceBlock('page_title_block');
$adminUser = $this->drupalCreateUser([
'administer themes',
'administer nodes',
'create article content',
'create page content',
]);
$this->drupalLogin($adminUser);
}
/**
* Get the theme name.
*
* @return string
* The theme to test.
*/
protected function getTheme(): string {
return explode('\\', get_class($this))[2];
}
/**
* Creates one node with title 0 and tests if the node title has the correct value.
*/
public function testNodeWithTitle0(): void {
$theme = $this->getTheme();
if ($theme !== $this->defaultTheme) {
$system_theme_config = $this->container->get('config.factory')
->getEditable('system.theme');
$system_theme_config
->set('default', $theme)
->save();
\Drupal::service('theme_installer')->install([$theme]);
}
// Create "Basic page" content with title 0.
$settings = [
'title' => 0,
];
$node = $this->drupalCreateNode($settings);
// Test that 0 appears as <title>.
$this->drupalGet('node/' . $node->id());
$this->assertSession()->titleEquals('0 | Drupal');
// Test that 0 appears in the template <h1>.
$this->assertSession()->elementTextEquals('xpath', '//h1', '0');
}
}
<?php
declare(strict_types=1);
namespace Drupal\Tests\claro\Functional;
use Drupal\Tests\system\Functional\Theme\NodeTitleTestBase;
/**
* Tests node title for claro.
*
* @group node
*/
class NodeTitleTest extends NodeTitleTestBase {
}
......@@ -20,7 +20,7 @@
%}
{{ title_prefix }}
{% if title|render|striptags|trim %}
{% if (title|render|striptags|trim is not empty) %}
<h1{{ title_attributes.addClass(classes) }}>{{ title }}</h1>
{% endif %}
{{ title_suffix }}
<?php
declare(strict_types=1);
namespace Drupal\Tests\olivero\Functional;
use Drupal\Tests\system\Functional\Theme\NodeTitleTestBase;
/**
* Tests node title for olivero.
*
* @group node
*/
class NodeTitleTest extends NodeTitleTestBase {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment