class ComponentRenderTest

Same name in this branch
  1. 10 core/modules/sdc/tests/src/FunctionalJavascript/ComponentRenderTest.php \Drupal\Tests\sdc\FunctionalJavascript\ComponentRenderTest
  2. 10 core/modules/sdc/tests/src/Functional/ComponentRenderTest.php \Drupal\Tests\sdc\Functional\ComponentRenderTest
  3. 10 core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php \Drupal\KernelTests\Components\ComponentRenderTest
  4. 10 core/tests/Drupal/FunctionalTests/Components/ComponentRenderTest.php \Drupal\FunctionalTests\Components\ComponentRenderTest
  5. 10 core/tests/Drupal/FunctionalJavascriptTests/Components/ComponentRenderTest.php \Drupal\FunctionalJavascriptTests\Components\ComponentRenderTest
Same name in other branches
  1. 11.x core/modules/sdc/tests/src/FunctionalJavascript/ComponentRenderTest.php \Drupal\Tests\sdc\FunctionalJavascript\ComponentRenderTest
  2. 11.x core/modules/sdc/tests/src/Kernel/ComponentRenderTest.php \Drupal\Tests\sdc\Kernel\ComponentRenderTest
  3. 11.x core/modules/sdc/tests/src/Functional/ComponentRenderTest.php \Drupal\Tests\sdc\Functional\ComponentRenderTest
  4. 11.x core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php \Drupal\KernelTests\Components\ComponentRenderTest
  5. 11.x core/tests/Drupal/FunctionalTests/Components/ComponentRenderTest.php \Drupal\FunctionalTests\Components\ComponentRenderTest
  6. 11.x core/tests/Drupal/FunctionalJavascriptTests/Components/ComponentRenderTest.php \Drupal\FunctionalJavascriptTests\Components\ComponentRenderTest

Tests the correct rendering of components.

@group sdc

@internal

Hierarchy

Expanded class hierarchy of ComponentRenderTest

File

core/modules/sdc/tests/src/Kernel/ComponentRenderTest.php, line 18

Namespace

Drupal\Tests\sdc\Kernel
View source
final class ComponentRenderTest extends ComponentKernelTestBase {
    use StringTranslationTrait;
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'sdc',
        'sdc_test',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected static $themes = [
        'sdc_theme_test',
    ];
    
    /**
     * Test that components render correctly.
     */
    public function testRender() : void {
        $this->checkIncludeDefaultContent();
        $this->checkIncludeDataMapping();
        $this->checkEmbedWithNested();
        $this->checkPropValidation();
        $this->checkArrayObjectTypeCast();
        $this->checkNonExistingComponent();
        $this->checkLibraryOverrides();
        $this->checkAttributeMerging();
        $this->checkRenderElementAlters();
        $this->checkSlots();
        $this->checkInvalidSlot();
        $this->checkEmptyProps();
    }
    
    /**
     * Check using a component with an include and default context.
     */
    protected function checkIncludeDefaultContent() : void {
        $build = [
            '#type' => 'inline_template',
            '#template' => "{% embed('sdc_theme_test_base:my-card-no-schema') %}{% block card_body %}Foo bar{% endblock %}{% endembed %}",
        ];
        $crawler = $this->renderComponentRenderArray($build);
        $this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test_base:my-card-no-schema"] .component--my-card-no-schema__body:contains("Foo bar")'));
    }
    
    /**
     * Check using a component with an include and no default context.
     *
     * This covers passing a render array to a 'string' prop, and mapping the
     * prop to a context variable.
     */
    protected function checkIncludeDataMapping() : void {
        $content = [
            'label' => [
                '#type' => 'html_tag',
                '#tag' => 'span',
                '#value' => 'Another button ç',
            ],
        ];
        $build = [
            '#type' => 'inline_template',
            '#context' => [
                'content' => $content,
            ],
            '#template' => "{{ include('sdc_test:my-button', { text: content.label, iconType: 'external' }, with_context = false) }}",
        ];
        $crawler = $this->renderComponentRenderArray($build);
        $this->assertNotEmpty($crawler->filter('#sdc-wrapper button:contains("Another button ç")'));
    }
    
    /**
     * Render a card with slots that include a CTA component.
     */
    protected function checkEmbedWithNested() : void {
        $content = [
            'heading' => [
                '#type' => 'html_tag',
                '#tag' => 'span',
                '#value' => 'Just a link',
            ],
        ];
        $build = [
            '#type' => 'inline_template',
            '#context' => [
                'content' => $content,
            ],
            '#template' => "{% embed 'sdc_theme_test:my-card' with { header: 'Card header', content: content } only %}{% block card_body %}This is a card with a CTA {{ include('sdc_test:my-cta', { text: content.heading, href: 'https://www.example.org', target: '_blank' }, with_context = false) }}{% endblock %}{% endembed %}",
        ];
        $crawler = $this->renderComponentRenderArray($build);
        $this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"] h2.component--my-card__header:contains("Card header")'));
        $this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"] .component--my-card__body:contains("This is a card with a CTA")'));
        $this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"] .component--my-card__body a[data-component-id="sdc_test:my-cta"]:contains("Just a link")'));
        $this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"] .component--my-card__body a[data-component-id="sdc_test:my-cta"][href="https://www.example.org"][target="_blank"]'));
        // Now render a component and assert it contains the debug comments.
        $build = [
            '#type' => 'component',
            '#component' => 'sdc_test:my-banner',
            '#props' => [
                'heading' => $this->t('I am a banner'),
                'ctaText' => $this->t('Click me'),
                'ctaHref' => 'https://www.example.org',
                'ctaTarget' => '',
            ],
            '#slots' => [
                'banner_body' => [
                    '#type' => 'html_tag',
                    '#tag' => 'p',
                    '#value' => $this->t('This is the contents of the banner body.'),
                ],
            ],
        ];
        $metadata = new BubbleableMetadata();
        $this->renderComponentRenderArray($build, $metadata);
        $this->assertEquals([
            'sdc/sdc_test--my-cta',
            'sdc/sdc_test--my-banner',
        ], $metadata->getAttachments()['library']);
    }
    
    /**
     * Check using the libraryOverrides.
     */
    protected function checkLibraryOverrides() : void {
        $build = [
            '#type' => 'inline_template',
            '#template' => "{{ include('sdc_theme_test:lib-overrides') }}",
        ];
        $metadata = new BubbleableMetadata();
        $this->renderComponentRenderArray($build, $metadata);
        $this->assertEquals([
            'sdc/sdc_theme_test--lib-overrides',
        ], $metadata->getAttachments()['library']);
    }
    
    /**
     * Ensures the schema violations are reported properly.
     */
    protected function checkPropValidation() : void {
        // 1. Violates the minLength for the text property.
        $content = [
            'label' => '1',
        ];
        $build = [
            '#type' => 'inline_template',
            '#context' => [
                'content' => $content,
            ],
            '#template' => "{{ include('sdc_test:my-button', { text: content.label, iconType: 'external' }, with_context = false) }}",
        ];
        try {
            $this->renderComponentRenderArray($build);
            $this->fail('Invalid prop did not cause an exception');
        } catch (\Throwable $e) {
            $this->addToAssertionCount(1);
        }
        // 2. Violates the required header property.
        $build = [
            '#type' => 'inline_template',
            '#context' => [],
            '#template' => "{{ include('sdc_theme_test:my-card', with_context = false) }}",
        ];
        try {
            $this->renderComponentRenderArray($build);
            $this->fail('Invalid prop did not cause an exception');
        } catch (\Throwable $e) {
            $this->addToAssertionCount(1);
        }
    }
    
    /**
     * Ensure fuzzy coercing of arrays and objects works properly.
     */
    protected function checkArrayObjectTypeCast() : void {
        $content = [
            'test' => [],
        ];
        $build = [
            '#type' => 'inline_template',
            '#context' => [
                'content' => $content,
            ],
            '#template' => "{{ include('sdc_test:array-to-object', { testProp: content.test }, with_context = false) }}",
        ];
        try {
            $this->renderComponentRenderArray($build);
            $this->addToAssertionCount(1);
        } catch (\Throwable $e) {
            $this->fail('Empty array was not converted to object');
        }
    }
    
    /**
     * Ensures that including an invalid component creates an error.
     */
    protected function checkNonExistingComponent() : void {
        $build = [
            '#type' => 'inline_template',
            '#context' => [],
            '#template' => "{{ include('sdc_test:INVALID', with_context = false) }}",
        ];
        try {
            $this->renderComponentRenderArray($build);
            $this->fail('Invalid prop did not cause an exception');
        } catch (\Throwable $e) {
            $this->addToAssertionCount(1);
        }
    }
    
    /**
     * Ensures the attributes are merged properly.
     */
    protected function checkAttributeMerging() : void {
        $content = [
            'label' => 'I am a labels',
        ];
        // 1. Check that if it exists Attribute object in the 'attributes' prop, you
        // get them merged.
        $build = [
            '#type' => 'inline_template',
            '#context' => [
                'content' => $content,
                'attributes' => new Attribute([
                    'data-merged-attributes' => 'yes',
                ]),
            ],
            '#template' => "{{ include('sdc_test:my-button', { text: content.label, iconType: 'external', attributes: attributes }, with_context = false) }}",
        ];
        $crawler = $this->renderComponentRenderArray($build);
        $this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-merged-attributes="yes"][data-component-id="sdc_test:my-button"]'), $crawler->outerHtml());
        // 2. Check that if the 'attributes' exists, but there is some other data
        // type, then we don't touch it.
        $build = [
            '#type' => 'inline_template',
            '#context' => [
                'content' => $content,
                'attributes' => 'hard-coded-attr',
            ],
            '#template' => "{{ include('sdc_theme_test_base:my-card-no-schema', { header: content.label, attributes: attributes }, with_context = false) }}",
        ];
        $crawler = $this->renderComponentRenderArray($build);
        // The default data attribute should be missing.
        $this->assertEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test_base:my-card-no-schema"]'), $crawler->outerHtml());
        $this->assertNotEmpty($crawler->filter('#sdc-wrapper [hard-coded-attr]'), $crawler->outerHtml());
        // 3. Check that if the 'attributes' is empty, we get the defaults.
        $build = [
            '#type' => 'inline_template',
            '#context' => [
                'content' => $content,
            ],
            '#template' => "{{ include('sdc_theme_test_base:my-card-no-schema', { header: content.label }, with_context = false) }}",
        ];
        $crawler = $this->renderComponentRenderArray($build);
        // The default data attribute should not be missing.
        $this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test_base:my-card-no-schema"]'), $crawler->outerHtml());
    }
    
    /**
     * Ensures the alter callbacks work properly.
     */
    public function checkRenderElementAlters() : void {
        $build = [
            '#type' => 'component',
            '#component' => 'sdc_test:my-banner',
            '#props' => [
                'heading' => $this->t('I am a banner'),
                'ctaText' => $this->t('Click me'),
                'ctaHref' => 'https://www.example.org',
                'ctaTarget' => '',
            ],
            '#propsAlter' => [
                fn($props) => [
                    $props,
                    'heading' => $this->t('I am another banner'),
                ],
            ],
            '#slots' => [
                'banner_body' => [
                    '#type' => 'html_tag',
                    '#tag' => 'p',
                    '#value' => $this->t('This is the contents of the banner body.'),
                ],
            ],
            '#slotsAlter' => [
                static fn($slots) => [
                    $slots,
                    'banner_body' => [
                        '#markup' => '<h2>Just something else.</h2>',
                    ],
                ],
            ],
        ];
        $crawler = $this->renderComponentRenderArray($build);
        $this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_test:my-banner"] .component--my-banner--header h3:contains("I am another banner")'));
        $this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_test:my-banner"] .component--my-banner--body:contains("Just something else.")'));
    }
    
    /**
     * Ensure that the slots allow a render array or a scalar when using the render element.
     */
    public function checkSlots() : void {
        $slots = [
            'This is the contents of the banner body.',
            [
                '#plain_text' => 'This is the contents of the banner body.',
            ],
        ];
        foreach ($slots as $slot) {
            $build = [
                '#type' => 'component',
                '#component' => 'sdc_test:my-banner',
                '#props' => [
                    'heading' => $this->t('I am a banner'),
                    'ctaText' => $this->t('Click me'),
                    'ctaHref' => 'https://www.example.org',
                    'ctaTarget' => '',
                ],
                '#slots' => [
                    'banner_body' => $slot,
                ],
            ];
            $crawler = $this->renderComponentRenderArray($build);
            $this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_test:my-banner"] .component--my-banner--body:contains("This is the contents of the banner body.")'));
        }
    }
    
    /**
     * Ensure that the slots throw an error for invalid slots.
     */
    public function checkInvalidSlot() : void {
        $build = [
            '#type' => 'component',
            '#component' => 'sdc_test:my-banner',
            '#props' => [
                'heading' => $this->t('I am a banner'),
                'ctaText' => $this->t('Click me'),
                'ctaHref' => 'https://www.example.org',
                'ctaTarget' => '',
            ],
            '#slots' => [
                'banner_body' => new \stdClass(),
            ],
        ];
        $this->expectException(InvalidComponentDataException::class);
        $this->expectExceptionMessage('Unable to render component "sdc_test:my-banner". A render array or a scalar is expected for the slot "banner_body" when using the render element with the "#slots" property');
        $this->renderComponentRenderArray($build);
    }
    
    /**
     * Ensure that components can have 0 props.
     */
    public function checkEmptyProps() : void {
        $build = [
            '#type' => 'component',
            '#component' => 'sdc_test:no-props',
            '#props' => [],
        ];
        $crawler = $this->renderComponentRenderArray($build);
        $this->assertEquals($crawler->filter('#sdc-wrapper')
            ->innerText(), 'This is a test string.');
    }
    
    /**
     * Ensures some key aspects of the plugin definition are correctly computed.
     *
     * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
     */
    public function testPluginDefinition() : void {
        $plugin_manager = \Drupal::service('plugin.manager.sdc');
        assert($plugin_manager instanceof ComponentPluginManager);
        $definition = $plugin_manager->getDefinition('sdc_test:my-banner');
        $this->assertSame('my-banner', $definition['machineName']);
        $this->assertStringEndsWith('sdc/tests/modules/sdc_test/components/my-banner', $definition['path']);
        $this->assertEquals([
            'core/drupal',
        ], $definition['library']['dependencies']);
        $this->assertNotEmpty($definition['library']['css']['component']);
        $this->assertSame('my-banner.twig', $definition['template']);
        $this->assertNotEmpty($definition['documentation']);
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title Overrides
AssertContentTrait::$content protected property The current raw content.
AssertContentTrait::$drupalSettings protected property The drupalSettings value from the current raw $content.
AssertContentTrait::$elements protected property The XML structure parsed from the current raw $content. 1
AssertContentTrait::$plainTextContent protected property The plain-text content of raw $content (text nodes).
AssertContentTrait::assertEscaped protected function Passes if the raw text IS found escaped on the loaded page, fail otherwise.
AssertContentTrait::assertField protected function Asserts that a field exists with the given name or ID.
AssertContentTrait::assertFieldById protected function Asserts that a field exists with the given ID and value.
AssertContentTrait::assertFieldByName protected function Asserts that a field exists with the given name and value.
AssertContentTrait::assertFieldByXPath protected function Asserts that a field exists in the current page by the given XPath.
AssertContentTrait::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
AssertContentTrait::assertFieldsByValue protected function Asserts that a field exists in the current page with a given Xpath result.
AssertContentTrait::assertLink protected function Passes if a link with the specified label is found.
AssertContentTrait::assertLinkByHref protected function Passes if a link containing a given href (part) is found.
AssertContentTrait::assertNoDuplicateIds protected function Asserts that each HTML ID is used for just a single element.
AssertContentTrait::assertNoEscaped protected function Passes if raw text IS NOT found escaped on loaded page, fail otherwise.
AssertContentTrait::assertNoField protected function Asserts that a field does not exist with the given name or ID.
AssertContentTrait::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
AssertContentTrait::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
AssertContentTrait::assertNoFieldByXPath protected function Asserts that a field does not exist or its value does not match, by XPath.
AssertContentTrait::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
AssertContentTrait::assertNoLink protected function Passes if a link with the specified label is not found.
AssertContentTrait::assertNoLinkByHref protected function Passes if a link containing a given href (part) is not found.
AssertContentTrait::assertNoLinkByHrefInMainRegion protected function Passes if a link containing a given href is not found in the main region.
AssertContentTrait::assertNoOption protected function Asserts that a select option in the current page does not exist.
AssertContentTrait::assertNoOptionSelected protected function Asserts that a select option in the current page is not checked.
AssertContentTrait::assertNoPattern protected function Triggers a pass if the perl regex pattern is not found in raw content.
AssertContentTrait::assertNoRaw protected function Passes if the raw text is NOT found on the loaded page, fail otherwise.
AssertContentTrait::assertNoText protected function Passes if the page (with HTML stripped) does not contains the text.
AssertContentTrait::assertNoTitle protected function Pass if the page title is not the given string.
AssertContentTrait::assertNoUniqueText protected function Passes if the text is found MORE THAN ONCE on the text version of the page.
AssertContentTrait::assertOption protected function Asserts that a select option in the current page exists.
AssertContentTrait::assertOptionByText protected function Asserts that a select option with the visible text exists.
AssertContentTrait::assertOptionSelected protected function Asserts that a select option in the current page is checked.
AssertContentTrait::assertOptionSelectedWithDrupalSelector protected function Asserts that a select option in the current page is checked.
AssertContentTrait::assertOptionWithDrupalSelector protected function Asserts that a select option in the current page exists.
AssertContentTrait::assertPattern protected function Triggers a pass if the Perl regex pattern is found in the raw content.
AssertContentTrait::assertRaw protected function Passes if the raw text IS found on the loaded page, fail otherwise.
AssertContentTrait::assertText protected function Passes if the page (with HTML stripped) contains the text.
AssertContentTrait::assertTextHelper protected function Helper for assertText and assertNoText.
AssertContentTrait::assertTextPattern protected function Asserts that a Perl regex pattern is found in the plain-text content.
AssertContentTrait::assertThemeOutput protected function Asserts themed output.
AssertContentTrait::assertTitle protected function Pass if the page title is the given string.
AssertContentTrait::assertUniqueText protected function Passes if the text is found ONLY ONCE on the text version of the page.
AssertContentTrait::assertUniqueTextHelper protected function Helper for assertUniqueText and assertNoUniqueText.
AssertContentTrait::buildXPathQuery protected function Builds an XPath query.
AssertContentTrait::constructFieldXpath protected function Helper: Constructs an XPath for the given set of attributes and value.
AssertContentTrait::cssSelect protected function Searches elements using a CSS selector in the raw content.
AssertContentTrait::getAllOptions protected function Get all option elements, including nested options, in a select.
AssertContentTrait::getDrupalSettings protected function Gets the value of drupalSettings for the currently-loaded page.
AssertContentTrait::getRawContent protected function Gets the current raw content.
AssertContentTrait::getSelectedItem protected function Get the selected value from a select field.
AssertContentTrait::getTextContent protected function Retrieves the plain-text content from the current raw content.
AssertContentTrait::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
AssertContentTrait::removeWhiteSpace protected function Removes all white-space between HTML tags from the raw content.
AssertContentTrait::setDrupalSettings protected function Sets the value of drupalSettings for the currently-loaded page.
AssertContentTrait::setRawContent protected function Sets the raw content (e.g. HTML).
AssertContentTrait::xpath protected function Performs an xpath search on the contents of the internal browser.
ComponentKernelTestBase::$manager protected property The component plugin manager.
ComponentKernelTestBase::$negotiator protected property The component negotiator.
ComponentKernelTestBase::setUp protected function Overrides KernelTestBase::setUp
ComponentRendererTrait::renderComponentRenderArray protected function Renders a component for testing sake.
ComponentRenderTest::$modules protected static property Modules to enable. Overrides ComponentKernelTestBase::$modules
ComponentRenderTest::$themes protected static property Themes to install. Overrides ComponentKernelTestBase::$themes
ComponentRenderTest::checkArrayObjectTypeCast protected function Ensure fuzzy coercing of arrays and objects works properly.
ComponentRenderTest::checkAttributeMerging protected function Ensures the attributes are merged properly.
ComponentRenderTest::checkEmbedWithNested protected function Render a card with slots that include a CTA component.
ComponentRenderTest::checkEmptyProps public function Ensure that components can have 0 props.
ComponentRenderTest::checkIncludeDataMapping protected function Check using a component with an include and no default context.
ComponentRenderTest::checkIncludeDefaultContent protected function Check using a component with an include and default context.
ComponentRenderTest::checkInvalidSlot public function Ensure that the slots throw an error for invalid slots.
ComponentRenderTest::checkLibraryOverrides protected function Check using the libraryOverrides.
ComponentRenderTest::checkNonExistingComponent protected function Ensures that including an invalid component creates an error.
ComponentRenderTest::checkPropValidation protected function Ensures the schema violations are reported properly.
ComponentRenderTest::checkRenderElementAlters public function Ensures the alter callbacks work properly.
ComponentRenderTest::checkSlots public function Ensure that the slots allow a render array or a scalar when using the render element.
ComponentRenderTest::testPluginDefinition public function Ensures some key aspects of the plugin definition are correctly computed.
ComponentRenderTest::testRender public function Test that components render correctly.
ConfigTestTrait::configImporter protected function Returns a ConfigImporter object to import test configuration.
ConfigTestTrait::copyConfig protected function Copies configuration objects from source storage to target storage.
ExtensionListTestTrait::getModulePath protected function Gets the path for the specified module.
ExtensionListTestTrait::getThemePath protected function Gets the path for the specified theme.
KernelTestBase::$backupGlobals protected property Back up and restore any global variables that may be changed by tests.
KernelTestBase::$backupStaticAttributes protected property Back up and restore static class properties that may be changed by tests.
KernelTestBase::$backupStaticAttributesBlacklist protected property Contains a few static class properties for performance.
KernelTestBase::$classLoader protected property
KernelTestBase::$configImporter protected property @todo Move into Config test base class. 6
KernelTestBase::$configSchemaCheckerExclusions protected static property An array of config object names that are excluded from schema checking. 3
KernelTestBase::$container protected property
KernelTestBase::$databasePrefix protected property
KernelTestBase::$keyValue protected property The key_value service that must persist between container rebuilds.
KernelTestBase::$preserveGlobalState protected property Do not forward any global state from the parent process to the processes
that run the actual tests.
KernelTestBase::$root protected property The app root.
KernelTestBase::$runTestInSeparateProcess protected property Kernel tests are run in separate processes because they allow autoloading
of code from extensions. Running the test in a separate process isolates
this behavior from other tests. Subclasses should not override this
property.
KernelTestBase::$siteDirectory protected property
KernelTestBase::$strictConfigSchema protected property Set to TRUE to strict check all configuration saved. 9
KernelTestBase::$usesSuperUserAccessPolicy protected property Set to TRUE to make user 1 a super user. 7
KernelTestBase::$vfsRoot protected property The virtual filesystem root directory.
KernelTestBase::assertPostConditions protected function 1
KernelTestBase::bootEnvironment protected function Bootstraps a basic test environment.
KernelTestBase::bootKernel protected function Bootstraps a kernel for a test. 1
KernelTestBase::config protected function Configuration accessor for tests. Returns non-overridden configuration.
KernelTestBase::disableModules protected function Disables modules for this test.
KernelTestBase::enableModules protected function Enables modules for this test. 1
KernelTestBase::getConfigSchemaExclusions protected function Gets the config schema exclusions for this test.
KernelTestBase::getDatabaseConnectionInfo protected function Returns the Database connection info to be used for this test. 2
KernelTestBase::getDatabasePrefix public function
KernelTestBase::getExtensionsForModules private function Returns Extension objects for $modules to install.
KernelTestBase::getModulesToEnable private static function Returns the modules to install for this test.
KernelTestBase::initFileCache protected function Initializes the FileCache component.
KernelTestBase::installConfig protected function Installs default configuration for a given list of modules.
KernelTestBase::installEntitySchema protected function Installs the storage schema for a specific entity type.
KernelTestBase::installSchema protected function Installs database tables from a module schema definition.
KernelTestBase::register public function Registers test-specific services. Overrides ServiceProviderInterface::register 27
KernelTestBase::render protected function Renders a render array. 1
KernelTestBase::setInstallProfile protected function Sets the install profile and rebuilds the container to update it.
KernelTestBase::setSetting protected function Sets an in-memory Settings variable.
KernelTestBase::setUpBeforeClass public static function 1
KernelTestBase::setUpFilesystem protected function Sets up the filesystem, so things like the file directory. 2
KernelTestBase::stop Deprecated protected function Stops test execution.
KernelTestBase::tearDown protected function 6
KernelTestBase::tearDownCloseDatabaseConnection public function @after
KernelTestBase::vfsDump protected function Dumps the current state of the virtual filesystem to STDOUT.
KernelTestBase::__get public function
KernelTestBase::__sleep public function Prevents serializing any properties.
PhpUnitWarnings::$deprecationWarnings private static property Deprecation warnings from PHPUnit to raise with @trigger_error().
PhpUnitWarnings::addWarning public function Converts PHPUnit deprecation warnings to E_USER_DEPRECATED.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers.
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
RandomGeneratorTrait::randomStringValidate Deprecated public function Callback for random string validation.
StorageCopyTrait::replaceStorageContents protected static function Copy the configuration from one storage to another and remove stale items.
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
TestRequirementsTrait::checkModuleRequirements Deprecated private function Checks missing module requirements.
TestRequirementsTrait::checkRequirements Deprecated protected function Check module requirements for the Drupal use case.
TestRequirementsTrait::getDrupalRoot protected static function Returns the Drupal root directory.

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