You are here

public function StyleSerializerKernelTest::testCalculateDepenencies in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/rest/tests/src/Kernel/Views/StyleSerializerKernelTest.php \Drupal\Tests\rest\Kernel\Views\StyleSerializerKernelTest::testCalculateDepenencies()

@covers ::calculateDependencies

File

core/modules/rest/tests/src/Kernel/Views/StyleSerializerKernelTest.php, line 37

Class

StyleSerializerKernelTest
@coversDefaultClass \Drupal\rest\Plugin\views\style\Serializer @group views

Namespace

Drupal\Tests\rest\Kernel\Views

Code

public function testCalculateDepenencies() {

  /** @var \Drupal\views\Entity\View $view */
  $view = View::load('test_serializer_display_entity');
  $display =& $view
    ->getDisplay('rest_export_1');
  $display['display_options']['defaults']['style'] = FALSE;
  $display['display_options']['style']['type'] = 'serializer';
  $display['display_options']['style']['options']['formats'] = [
    'json',
    'xml',
  ];
  $view
    ->save();
  $view
    ->calculateDependencies();
  $this
    ->assertEquals([
    'module' => [
      'rest',
      'serialization',
      'user',
    ],
  ], $view
    ->getDependencies());
  \Drupal::service('module_installer')
    ->install([
    'hal',
  ]);
  $view = View::load('test_serializer_display_entity');
  $display =& $view
    ->getDisplay('rest_export_1');
  $display['display_options']['style']['options']['formats'] = [
    'json',
    'xml',
    'hal_json',
  ];
  $view
    ->save();
  $view
    ->calculateDependencies();
  $this
    ->assertEquals([
    'module' => [
      'hal',
      'rest',
      'serialization',
      'user',
    ],
  ], $view
    ->getDependencies());
}