You are here

public function FieldFieldTest::testComplexRender in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php \Drupal\Tests\views\Kernel\Handler\FieldFieldTest::testComplexRender()
  2. 9 core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php \Drupal\Tests\views\Kernel\Handler\FieldFieldTest::testComplexRender()

Tests the output of a view with complex field configuration.

File

core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php, line 398

Class

FieldFieldTest
Provides some integration tests for the Field handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testComplexRender() {
  $executable = Views::getView('test_field_field_complex_test');
  $executable
    ->execute();
  $date_formatter = \Drupal::service('date.formatter');
  $this
    ->assertEquals($this->testUsers[0]
    ->getTimeZone(), $executable
    ->getStyle()
    ->getField(0, 'timezone'));
  $this
    ->assertEquals("1, 3", $executable
    ->getStyle()
    ->getField(0, 'field_test_multiple'));
  $this
    ->assertEquals("1", $executable
    ->getStyle()
    ->getField(0, 'field_test_multiple_1'));
  $this
    ->assertEquals("3", $executable
    ->getStyle()
    ->getField(0, 'field_test_multiple_2'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[0]
    ->getCreatedTime(), 'custom', 'Y'), $executable
    ->getStyle()
    ->getField(0, 'created'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[0]
    ->getCreatedTime(), 'custom', 'H:i:s'), $executable
    ->getStyle()
    ->getField(0, 'created_1'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[0]
    ->getCreatedTime(), 'fallback'), $executable
    ->getStyle()
    ->getField(0, 'created_2'));
  $this
    ->assertEquals($this->testUsers[1]
    ->getTimeZone(), $executable
    ->getStyle()
    ->getField(1, 'timezone'));
  $this
    ->assertEquals("7, 0", $executable
    ->getStyle()
    ->getField(1, 'field_test_multiple'));
  $this
    ->assertEquals("7", $executable
    ->getStyle()
    ->getField(1, 'field_test_multiple_1'));
  $this
    ->assertEquals("0", $executable
    ->getStyle()
    ->getField(1, 'field_test_multiple_2'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[1]
    ->getCreatedTime(), 'custom', 'Y'), $executable
    ->getStyle()
    ->getField(1, 'created'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[1]
    ->getCreatedTime(), 'custom', 'H:i:s'), $executable
    ->getStyle()
    ->getField(1, 'created_1'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[1]
    ->getCreatedTime(), 'fallback'), $executable
    ->getStyle()
    ->getField(1, 'created_2'));
  $this
    ->assertEquals($this->testUsers[2]
    ->getTimeZone(), $executable
    ->getStyle()
    ->getField(2, 'timezone'));
  $this
    ->assertEquals("3, 5", $executable
    ->getStyle()
    ->getField(2, 'field_test_multiple'));
  $this
    ->assertEquals("3", $executable
    ->getStyle()
    ->getField(2, 'field_test_multiple_1'));
  $this
    ->assertEquals("5", $executable
    ->getStyle()
    ->getField(2, 'field_test_multiple_2'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[2]
    ->getCreatedTime(), 'custom', 'Y'), $executable
    ->getStyle()
    ->getField(2, 'created'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[2]
    ->getCreatedTime(), 'custom', 'H:i:s'), $executable
    ->getStyle()
    ->getField(2, 'created_1'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[2]
    ->getCreatedTime(), 'fallback'), $executable
    ->getStyle()
    ->getField(2, 'created_2'));
  $this
    ->assertEquals($this->testUsers[3]
    ->getTimeZone(), $executable
    ->getStyle()
    ->getField(3, 'timezone'));
  $this
    ->assertEquals("9, 9", $executable
    ->getStyle()
    ->getField(3, 'field_test_multiple'));
  $this
    ->assertEquals("9", $executable
    ->getStyle()
    ->getField(3, 'field_test_multiple_1'));
  $this
    ->assertEquals("9", $executable
    ->getStyle()
    ->getField(3, 'field_test_multiple_2'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[3]
    ->getCreatedTime(), 'custom', 'Y'), $executable
    ->getStyle()
    ->getField(3, 'created'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[3]
    ->getCreatedTime(), 'custom', 'H:i:s'), $executable
    ->getStyle()
    ->getField(3, 'created_1'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[3]
    ->getCreatedTime(), 'fallback'), $executable
    ->getStyle()
    ->getField(3, 'created_2'));
  $this
    ->assertEquals($this->testUsers[4]
    ->getTimeZone(), $executable
    ->getStyle()
    ->getField(4, 'timezone'));
  $this
    ->assertEquals("9, 0", $executable
    ->getStyle()
    ->getField(4, 'field_test_multiple'));
  $this
    ->assertEquals("9", $executable
    ->getStyle()
    ->getField(4, 'field_test_multiple_1'));
  $this
    ->assertEquals("0", $executable
    ->getStyle()
    ->getField(4, 'field_test_multiple_2'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[4]
    ->getCreatedTime(), 'custom', 'Y'), $executable
    ->getStyle()
    ->getField(4, 'created'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[4]
    ->getCreatedTime(), 'custom', 'H:i:s'), $executable
    ->getStyle()
    ->getField(4, 'created_1'));
  $this
    ->assertEquals($date_formatter
    ->format($this->testUsers[4]
    ->getCreatedTime(), 'fallback'), $executable
    ->getStyle()
    ->getField(4, 'created_2'));
}