2c59e5c50fe84ec0c7888e02f0d84e0a7d273821
[yaffs-website] / web / core / modules / block_content / tests / src / Functional / Views / BlockContentWizardTest.php
1 <?php
2
3 namespace Drupal\Tests\block_content\Functional\Views;
4
5 use Drupal\Tests\block_content\Functional\BlockContentTestBase;
6
7 /**
8  * Tests block_content wizard and generic entity integration.
9  *
10  * @group block_content
11  */
12 class BlockContentWizardTest extends BlockContentTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = ['block_content', 'views_ui'];
18
19   /**
20    * {@inheritdoc}
21    */
22   protected function setUp() {
23     parent::setUp();
24     $this->drupalLogin($this->drupalCreateUser(['administer views']));
25     $this->createBlockContentType('Basic block');
26   }
27
28   /**
29    * Tests creating a 'block_content' entity view.
30    */
31   public function testViewAddBlockContent() {
32     $view = [];
33     $view['label'] = $this->randomMachineName(16);
34     $view['id'] = strtolower($this->randomMachineName(16));
35     $view['description'] = $this->randomMachineName(16);
36     $view['page[create]'] = FALSE;
37     $view['show[wizard_key]'] = 'block_content';
38     $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
39
40     $view_storage_controller = $this->container->get('entity_type.manager')->getStorage('view');
41     /** @var \Drupal\views\Entity\View $view */
42     $view = $view_storage_controller->load($view['id']);
43
44     $display_options = $view->getDisplay('default')['display_options'];
45
46     $this->assertEquals('block_content', $display_options['filters']['reusable']['entity_type']);
47     $this->assertEquals('reusable', $display_options['filters']['reusable']['entity_field']);
48     $this->assertEquals('boolean', $display_options['filters']['reusable']['plugin_id']);
49     $this->assertEquals('1', $display_options['filters']['reusable']['value']);
50   }
51
52 }