StyleSerializerKernelTest.php

Same filename in this branch
  1. 9 core/modules/rest/tests/src/Kernel/Views/StyleSerializerKernelTest.php
Same filename in other branches
  1. 8.9.x core/modules/rest/tests/src/Kernel/Views/StyleSerializerKernelTest.php
  2. 10 core/modules/rest/tests/src/Kernel/Views/StyleSerializerKernelTest.php
  3. 11.x core/modules/rest/tests/src/Kernel/Views/StyleSerializerKernelTest.php

Namespace

Drupal\Tests\hal\Kernel\rest\Views

File

core/modules/hal/tests/src/Kernel/rest/Views/StyleSerializerKernelTest.php

View source
<?php

namespace Drupal\Tests\hal\Kernel\rest\Views;

use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Entity\View;
use Drupal\views\Tests\ViewTestData;

/**
 * @coversDefaultClass \Drupal\rest\Plugin\views\style\Serializer
 * @group hal
 * @group legacy
 */
class StyleSerializerKernelTest extends ViewsKernelTestBase {
    
    /**
     * {@inheritdoc}
     */
    public static $testViews = [
        'test_serializer_display_entity',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'hal',
        'hal_test_views',
        'serialization',
        'rest',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected function setUp($import_test_views = TRUE) : void {
        parent::setUp($import_test_views);
        ViewTestData::createTestViews(static::class, [
            'hal_test_views',
        ]);
    }
    
    /**
     * @covers ::calculateDependencies
     */
    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',
            'hal_json',
        ];
        $view->save();
        $view->calculateDependencies();
        $this->assertEquals([
            'module' => [
                'hal',
                'rest',
                'serialization',
                'user',
            ],
        ], $view->getDependencies());
    }

}

Classes

Title Deprecated Summary
StyleSerializerKernelTest @coversDefaultClass \Drupal\rest\Plugin\views\style\Serializer @group hal @group legacy

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