FormatPluralUpdateTest.php

Namespace

Drupal\Tests\views\Functional\Update

File

core/modules/views/tests/src/Functional/Update/FormatPluralUpdateTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\views\Functional\Update;

use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Drupal\views\Entity\View;

/**
 * Tests the upgrade path for converting format_plural from integer to boolean.
 *
 * @group Update
 *
 * @see views_post_update_format_plural()
 */
class FormatPluralUpdateTest extends UpdatePathTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected function setDatabaseDumpFiles() : void {
    $this->databaseDumpFiles = [
      __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-10.3.0.filled.standard.php.gz',
      __DIR__ . '/../../../fixtures/update/format-plural.php',
    ];
  }
  
  /**
   * Tests that fields with the format_plural option are updated properly.
   */
  public function testViewsFieldFormatPluralConversion() : void {
    $view = View::load('test_format_plural_update');
    $data = $view->toArray();
    $this->assertSame(0, $data['display']['default']['display_options']['fields']['uid']['format_plural']);
    $this->runUpdates();
    $view = View::load('test_format_plural_update');
    $data = $view->toArray();
    // Ensure that integer 0 has become a boolean false.
    $this->assertFalse($data['display']['default']['display_options']['fields']['uid']['format_plural']);
  }

}

Classes

Title Deprecated Summary
FormatPluralUpdateTest Tests the upgrade path for converting format_plural from integer to boolean.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.