Namespace
Drupal\Tests\views\Functional\Update
File
core/modules/views/tests/src/Functional/Update/ViewsAddDefaultPaginationHeaderTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\views\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Drupal\views\Entity\View;
class ViewsAddDefaultPaginationHeaderTest extends UpdatePathTestBase {
protected static $modules = [
'node',
'taxonomy',
'user',
];
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz',
__DIR__ . '/../../../fixtures/update/add_pagination_heading.php',
];
}
protected function setUp() : void {
parent::setUp();
$this
->installModulesFromClassProperty($this->container);
}
public function testViewsPostUpdatePaginationHeadingLevel() {
$view = View::load('add_pagination_heading');
$data = $view
->toArray();
$counter = 0;
foreach ($data['display'] as $display) {
if (array_key_exists('pager', $display['display_options'])) {
$pager = $display['display_options']['pager'];
if (is_array($pager) && array_key_exists('options', $pager)) {
$this
->assertArrayNotHasKey('pagination_heading_level', $pager['options']);
$counter++;
}
}
}
$this
->assertGreaterThan(0, $counter);
$this
->runUpdates();
$view = View::load('add_pagination_heading');
$data = $view
->toArray();
$allow_pager_type_update = [
'mini',
'full',
];
$counterHasPager = 0;
$counterNoPager = 0;
foreach ($data['display'] as $display) {
if (array_key_exists('pager', $display['display_options'])) {
$pager = $display['display_options']['pager'];
if (is_array($pager) && array_key_exists('options', $pager)) {
if (in_array($pager['type'], $allow_pager_type_update)) {
$this
->assertArrayHasKey('pagination_heading_level', $pager['options']);
$counterHasPager++;
}
else {
$this
->assertArrayNotHasKey('pagination_heading_level', $pager['options']);
$counterNoPager++;
}
}
}
}
$this
->assertGreaterThan(0, $counterHasPager);
$this
->assertGreaterThan(0, $counterNoPager);
}
}
Classes