Same name in other branches
  1. 8.x-3.x tests/src/Kernel/QuicktabsConfigSchemaTest.php \Drupal\Tests\quicktabs\Kernel\QuicktabsConfigSchemaTest

Tests the quicktabs config schema.

@group quicktabs

Hierarchy

  • class \Drupal\Tests\quicktabs\Kernel\QuicktabsConfigSchemaTest extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\SchemaCheckTestTrait

Expanded class hierarchy of QuicktabsConfigSchemaTest

Fichier

tests/src/Kernel/QuicktabsConfigSchemaTest.php, line 14

Namespace

Drupal\Tests\quicktabs\Kernel
View source
class QuicktabsConfigSchemaTest extends KernelTestBase {
    use SchemaCheckTestTrait;
    
    /**
     * {@inheritdoc}
     */
    public static $modules = [
        'quicktabs',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() : void {
        parent::setUp();
        $this->typedConfig = \Drupal::service('config.typed');
        $this->tabTypeManager = \Drupal::service('plugin.manager.tab_type');
        $this->tabRendererManager = \Drupal::service('plugin.manager.tab_renderer');
    }
    
    /**
     * Tests the block config schema for block plugins.
     */
    public function testBlockConfigSchema() {
        foreach ($this->tabTypeManager
            ->getDefinitions() as $tab_type_id => $definition) {
            $id = strtolower($this->randomMachineName());
            $quicktabs = QuickTabsInstance::create([
                'id' => $id,
                'langcode' => 'es',
                'status' => TRUE,
                'dependencies' => [],
                'label' => 'test',
                'renderer' => 'quick_tabs',
                'options' => [
                    'accordion_tabs' => [
                        'jquery_ui' => [
                            'collapsible' => FALSE,
                            'heightStyle' => 'auto',
                        ],
                    ],
                    'quick_tabs' => [
                        'ajax' => FALSE,
                    ],
                ],
                'hide_empty_tabs' => TRUE,
                'default_tab' => 1,
                'configuration_data' => [
                    [
                        'title' => 'tab 1',
                        'weight' => 0,
                        'type' => 'block_content',
                        'content' => [
                            'view_content' => [
                                'options' => [
                                    'vid' => 'block_content',
                                    'display' => 'default',
                                    'args' => '',
                                ],
                            ],
                            'node_content' => [
                                'options' => [
                                    'nid' => '',
                                    'view_mode' => 'full',
                                    'hide_title' => TRUE,
                                ],
                            ],
                            'block_content' => [
                                'options' => [
                                    'bid' => 'some_block_here',
                                    'block_title' => 'abc',
                                    'display_title' => TRUE,
                                ],
                            ],
                            'qtabs_content' => [
                                'options' => [
                                    'machine_name' => '',
                                ],
                            ],
                        ],
                    ],
                    [
                        'title' => 'tab 2',
                        'weight' => 0,
                        'type' => 'node_content',
                        'content' => [
                            'view_content' => [
                                'options' => [
                                    'vid' => 'block_content',
                                    'display' => 'default',
                                    'args' => '',
                                ],
                            ],
                            'node_content' => [
                                'options' => [
                                    'nid' => '1',
                                    'view_mode' => 'full',
                                    'hide_title' => FALSE,
                                ],
                            ],
                            'block_content' => [
                                'options' => [
                                    'bid' => 'some_block_here',
                                    'block_title' => 'abc',
                                    'display_title' => TRUE,
                                ],
                            ],
                            'qtabs_content' => [
                                'options' => [
                                    'machine_name' => '',
                                ],
                            ],
                        ],
                    ],
                ],
            ]);
            $quicktabs->save();
            $config = $this->config("quicktabs.quicktabs_instance.{$id}");
            $this->assertEquals($config->get('id'), $id);
            $this->assertConfigSchema($this->typedConfig, $config->getName(), $config->get());
        }
    }

}

Members