RestExportAuthTest.php

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

Namespace

Drupal\Tests\rest\Kernel\Views

File

core/modules/rest/tests/src/Kernel/Views/RestExportAuthTest.php

View source
<?php

namespace Drupal\Tests\rest\Kernel\Views;

use Drupal\Tests\views\Kernel\ViewsKernelTestBase;

/**
 * Tests the auth option of rest exports.
 *
 * @coversDefaultClass \Drupal\rest\Plugin\views\display\RestExport
 *
 * @group rest
 */
class RestExportAuthTest extends ViewsKernelTestBase {
    
    /**
     * {@inheritdoc}
     */
    public static $modules = [
        'node',
        'rest',
        'views_ui',
        'basic_auth',
        'serialization',
        'rest',
        'user',
    ];
    
    /**
     * {@inheritdoc}
     */
    public static $testViews = [
        'rest_export_with_authorization_correction',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected function setUp($import_test_views = TRUE) {
        parent::setUp($import_test_views);
        $this->installConfig([
            'user',
        ]);
    }
    
    /**
     * Ensures that rest export auth settings are automatically corrected.
     *
     * @see rest_update_8401()
     * @see rest_views_presave()
     * @see \Drupal\Tests\rest\Functional\Update\RestExportAuthCorrectionUpdateTest
     */
    public function testAuthCorrection() {
        // Get particular view.
        $view = \Drupal::entityTypeManager()->getStorage('view')
            ->load('rest_export_with_authorization_correction');
        $displays = $view->get('display');
        $this->assertSame($displays['rest_export_1']['display_options']['auth'], [
            'cookie',
        ], 'Cookie is used for authentication');
    }

}

Classes

Title Deprecated Summary
RestExportAuthTest Tests the auth option of rest exports.

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