6570706f770dd4e5f841d03da985871cdbf57d85
[yaffs-website] / web / core / modules / rest / tests / src / Kernel / Views / RestExportAuthTest.php
1 <?php
2
3 namespace Drupal\Tests\rest\Kernel\Views;
4
5 use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
6
7 /**
8  * Tests the auth option of rest exports.
9  *
10  * @coversDefaultClass \Drupal\rest\Plugin\views\display\RestExport
11  *
12  * @group rest
13  */
14 class RestExportAuthTest extends ViewsKernelTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = [
20     'node',
21     'rest',
22     'views_ui',
23     'basic_auth',
24     'serialization',
25     'rest',
26     'user',
27   ];
28
29   /**
30    * {@inheritdoc}
31    */
32   public static $testViews = ['rest_export_with_authorization_correction'];
33
34   /**
35    * {@inheritdoc}
36    */
37   protected function setUp($import_test_views = TRUE) {
38     parent::setUp($import_test_views);
39
40     $this->installConfig(['user']);
41   }
42
43   /**
44    * Ensures that rest export auth settings are automatically corrected.
45    *
46    * @see rest_update_8401()
47    * @see rest_views_presave()
48    * @see \Drupal\Tests\rest\Functional\Update\RestExportAuthCorrectionUpdateTest
49    */
50   public function testAuthCorrection() {
51     // Get particular view.
52     $view = \Drupal::entityTypeManager()
53       ->getStorage('view')
54       ->load('rest_export_with_authorization_correction');
55     $displays = $view->get('display');
56     $this->assertSame($displays['rest_export_1']['display_options']['auth'], ['cookie'], 'Cookie is used for authentication');
57   }
58
59 }