class ComponentRenderTest
Same name in this branch
- main core/tests/Drupal/KernelTests/Component/ComponentRenderTest.php \Drupal\KernelTests\Component\ComponentRenderTest
- main core/tests/Drupal/FunctionalTests/Components/ComponentRenderTest.php \Drupal\FunctionalTests\Components\ComponentRenderTest
- main core/tests/Drupal/FunctionalJavascriptTests/Components/ComponentRenderTest.php \Drupal\FunctionalJavascriptTests\Components\ComponentRenderTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php \Drupal\KernelTests\Components\ComponentRenderTest
- 11.x core/tests/Drupal/KernelTests/Component/ComponentRenderTest.php \Drupal\KernelTests\Component\ComponentRenderTest
- 11.x core/tests/Drupal/FunctionalTests/Components/ComponentRenderTest.php \Drupal\FunctionalTests\Components\ComponentRenderTest
- 11.x core/tests/Drupal/FunctionalJavascriptTests/Components/ComponentRenderTest.php \Drupal\FunctionalJavascriptTests\Components\ComponentRenderTest
- 10 core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php \Drupal\KernelTests\Components\ComponentRenderTest
- 10 core/tests/Drupal/FunctionalTests/Components/ComponentRenderTest.php \Drupal\FunctionalTests\Components\ComponentRenderTest
- 10 core/tests/Drupal/FunctionalJavascriptTests/Components/ComponentRenderTest.php \Drupal\FunctionalJavascriptTests\Components\ComponentRenderTest
Tests the correct rendering of components.
Attributes
#[Group('sdc')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Components\ComponentKernelTestBase extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\Components\ComponentRenderTest uses \Drupal\Core\StringTranslation\StringTranslationTrait extends \Drupal\KernelTests\Components\ComponentKernelTestBase
- class \Drupal\KernelTests\Components\ComponentKernelTestBase extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ComponentRenderTest
File
-
core/
tests/ Drupal/ KernelTests/ Components/ ComponentRenderTest.php, line 18
Namespace
Drupal\KernelTests\ComponentsView source
class ComponentRenderTest extends ComponentKernelTestBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'sdc_test',
];
/**
* {@inheritdoc}
*/
protected static $themes = [
'sdc_theme_test',
];
/**
* Check using a component with an include and default context.
*/
public function testRenderIncludeDefaultContent() : 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.
*/
public function testRenderIncludeDataMapping() : 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.
*/
public function testRenderEmbedWithNested() : 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 { variant: 'horizontal', 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' => 'I am a banner',
'ctaText' => 'Click me',
'ctaHref' => 'https://www.example.org',
'ctaTarget' => '',
],
'#slots' => [
'banner_body' => [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => 'This is the contents of the banner body.',
],
],
];
$metadata = new BubbleableMetadata();
$this->renderComponentRenderArray($build, $metadata);
$this->assertEquals([
'core/components.sdc_test--my-cta',
'core/components.sdc_test--my-banner',
], $metadata->getAttachments()['library']);
}
/**
* Check using the libraryOverrides.
*/
public function testRenderLibraryOverrides() : void {
$build = [
'#type' => 'inline_template',
'#template' => "{{ include('sdc_theme_test:lib-overrides') }}",
];
$metadata = new BubbleableMetadata();
$this->renderComponentRenderArray($build, $metadata);
$this->assertEquals([
'core/components.sdc_theme_test--lib-overrides',
], $metadata->getAttachments()['library']);
}
/**
* Ensures the schema violations are reported properly.
*/
public function testRenderPropValidation() : 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) {
$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) {
$this->addToAssertionCount(1);
}
}
/**
* Ensure fuzzy coercing of arrays and objects works properly.
*/
public function testRenderArrayObjectTypeCast() : 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) {
$this->fail('Empty array was not converted to object');
}
}
/**
* Ensures that including an invalid component creates an error.
*/
public function testRenderNonExistingComponent() : 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) {
$this->addToAssertionCount(1);
}
}
/**
* Ensures the attributes are merged properly.
*/
public function testRenderAttributeMerging() : 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 element and prop attributes are merged properly.
*/
public function testCheckElementAttributesAndPropAttributesMerging() : void {
// Test no attributes.
// Prop: no. Element: no.
$build = [
'#type' => 'component',
'#component' => 'sdc_theme_test:my-card',
'#props' => [
'header' => 'Drupal.org',
],
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"][foo="bar"]'), $crawler->outerHtml());
$this->assertEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"][bar="fpo"]'), $crawler->outerHtml());
// Test for just prop attributes.
// Prop: object. Element: no.
$build = [
'#type' => 'component',
'#component' => 'sdc_theme_test:my-card',
'#props' => [
'header' => 'Drupal.org',
'attributes' => new Attribute([
'foo' => 'bar',
]),
],
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"][foo="bar"]'), $crawler->outerHtml());
// Test for prop attributes and element attributes as Attribute object.
// Prop: object. Element: object.
$build = [
'#type' => 'component',
'#component' => 'sdc_theme_test:my-card',
'#props' => [
'header' => 'Drupal.org',
'attributes' => new Attribute([
'foo' => 'bar',
]),
],
'#attributes' => new Attribute([
'bar' => 'foo',
]),
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"][foo="bar"][bar="foo"]'), $crawler->outerHtml());
// Test for no prop attributes and element attributes as Attribute object.
// Prop: no. Element: object.
$build = [
'#type' => 'component',
'#component' => 'sdc_theme_test:my-card',
'#props' => [
'header' => 'Drupal.org',
],
'#attributes' => new Attribute([
'bar' => 'foo',
]),
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"][bar="foo"]'), $crawler->outerHtml());
// Test for prop attributes and element attributes as Attribute array.
// Prop: object. Element: array.
$build = [
'#type' => 'component',
'#component' => 'sdc_theme_test:my-card',
'#props' => [
'header' => 'Drupal.org',
'attributes' => new Attribute([
'foo' => 'bar',
]),
],
'#attributes' => [
'bar' => 'foo',
],
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"][foo="bar"][bar="foo"]'), $crawler->outerHtml());
// Test for no prop attributes and element attributes as array.
// Prop: no. Element: array.
$build = [
'#type' => 'component',
'#component' => 'sdc_theme_test:my-card',
'#props' => [
'header' => 'Drupal.org',
],
'#attributes' => [
'bar' => 'foo',
],
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"][bar="foo"]'), $crawler->outerHtml());
// Prop: array. Element: no.
$build = [
'#type' => 'component',
'#component' => 'sdc_theme_test:my-card',
'#props' => [
'header' => 'Drupal.org',
'attributes' => [
'foo' => 'bar',
],
],
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"][foo="bar"]'), $crawler->outerHtml());
// Prop: array. Element: object.
$build = [
'#type' => 'component',
'#component' => 'sdc_theme_test:my-card',
'#props' => [
'header' => 'Drupal.org',
'attributes' => [
'foo' => 'bar',
],
],
'#attributes' => new Attribute([
'bar' => 'foo',
]),
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"][foo="bar"][bar="foo"]'), $crawler->outerHtml());
// Prop: array. Element: array.
$build = [
'#type' => 'component',
'#component' => 'sdc_theme_test:my-card',
'#props' => [
'header' => 'Drupal.org',
'attributes' => [
'foo' => 'bar',
],
],
'#attributes' => [
'bar' => 'foo',
],
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"][foo="bar"][bar="foo"]'), $crawler->outerHtml());
// Test overlapping attributes.
$build = [
'#type' => 'component',
'#component' => 'sdc_theme_test:my-card',
'#props' => [
'header' => 'Drupal.org',
'attributes' => new Attribute([
'foo' => 'bar',
]),
],
'#attributes' => [
'foo' => 'baz',
],
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"][foo="bar"]'), $crawler->outerHtml());
// Test array properties attributes.
$build = [
'#type' => 'component',
'#component' => 'sdc_theme_test:my-card',
'#props' => [
'header' => 'Drupal.org',
'attributes' => new Attribute([
'class' => [
'foo',
'bar',
],
]),
],
'#attributes' => [
'class' => [
'baz',
],
],
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertNotEmpty($crawler->filter('#sdc-wrapper [data-component-id="sdc_theme_test:my-card"][class="baz foo bar"]'), $crawler->outerHtml());
}
/**
* Ensures the alter callbacks work properly.
*/
public function testRenderElementAlters() : void {
$build = [
'#type' => 'component',
'#component' => 'sdc_test:my-banner',
'#props' => [
'heading' => 'I am a banner',
'ctaText' => 'Click me',
'ctaHref' => 'https://www.example.org',
'ctaTarget' => '',
],
'#propsAlter' => [
fn($props): array => [
$props,
'heading' => 'I am another banner',
],
],
'#slots' => [
'banner_body' => [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => 'This is the contents of the banner body.',
],
],
'#slotsAlter' => [
static fn($slots): array => [
$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 testRenderSlots() : 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' => 'I am a banner',
'ctaText' => '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 testRenderInvalidSlot() : void {
$build = [
'#type' => 'component',
'#component' => 'sdc_test:my-banner',
'#props' => [
'heading' => 'I am a banner',
'ctaText' => '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 testRenderEmptyProps() : 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.');
}
/**
* Ensure that components variants render.
*/
public function testVariants() : void {
$build = [
'#type' => 'component',
'#component' => 'sdc_test:my-cta',
'#variant' => 'primary',
'#props' => [
'text' => 'Test link',
],
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertNotEmpty($crawler->filter('#sdc-wrapper a[data-component-id="sdc_test:my-cta"][data-component-variant="primary"][class*="my-cta-primary"]'));
// If there were an existing prop named variant, we don't override that for BC reasons.
$build = [
'#type' => 'component',
'#component' => 'sdc_test:my-cta-with-variant-prop',
'#variant' => 'tertiary',
'#props' => [
'text' => 'Test link',
'variant' => 'secondary',
],
];
$crawler = $this->renderComponentRenderArray($build);
$this->assertEmpty($crawler->filter('#sdc-wrapper a[data-component-id="sdc_test:my-cta-with-variant-prop"][data-component-variant="tertiary"]'));
$this->assertNotEmpty($crawler->filter('#sdc-wrapper a[data-component-id="sdc_test:my-cta-with-variant-prop"][data-component-variant="secondary"]'));
}
/**
* 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('system/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 |
|---|---|---|---|---|---|
| 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. | ||
| 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 | Deprecated | 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 | Deprecated | 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 | Deprecated | 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 | Deprecated | protected | function | Asserts that a field does not exist with the given name or ID. | |
| AssertContentTrait::assertNoFieldById | Deprecated | protected | function | Asserts that a field does not exist with the given ID and value. | |
| AssertContentTrait::assertNoFieldByName | Deprecated | protected | function | Asserts that a field does not exist with the given name and value. | |
| AssertContentTrait::assertNoFieldByXPath | Deprecated | protected | function | Asserts that a field does not exist or its value does not match, by XPath. | |
| AssertContentTrait::assertNoFieldChecked | Deprecated | 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 | Deprecated | protected | function | Passes if a link containing a given href (part) is not found. | |
| AssertContentTrait::assertNoLinkByHrefInMainRegion | Deprecated | protected | function | Passes if a link containing a given href is not found in the main region. | |
| AssertContentTrait::assertNoOption | Deprecated | protected | function | Asserts that a select option in the current page does not exist. | |
| AssertContentTrait::assertNoOptionSelected | Deprecated | 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 | Deprecated | 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 | Deprecated | protected | function | Asserts that a select option with the visible text exists. | |
| AssertContentTrait::assertOptionSelected | Deprecated | protected | function | Asserts that a select option in the current page is checked. | |
| AssertContentTrait::assertOptionSelectedWithDrupalSelector | Deprecated | 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 | Deprecated | 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 | Deprecated | protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | |
| AssertContentTrait::assertUniqueTextHelper | Deprecated | 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::renderComponentRenderArray | protected | function | Renders a component for testing sake. | ||
| ComponentKernelTestBase::setUp | protected | function | Overrides KernelTestBase::setUp | ||
| ComponentRenderTest::$modules | protected static | property | Modules to install. | Overrides ComponentKernelTestBase::$modules | |
| ComponentRenderTest::$themes | protected static | property | Themes to install. | Overrides ComponentKernelTestBase::$themes | |
| ComponentRenderTest::testCheckElementAttributesAndPropAttributesMerging | public | function | Ensures the element and prop attributes are merged properly. | ||
| ComponentRenderTest::testPluginDefinition | public | function | Ensures some key aspects of the plugin definition are correctly computed. | ||
| ComponentRenderTest::testRenderArrayObjectTypeCast | public | function | Ensure fuzzy coercing of arrays and objects works properly. | ||
| ComponentRenderTest::testRenderAttributeMerging | public | function | Ensures the attributes are merged properly. | ||
| ComponentRenderTest::testRenderElementAlters | public | function | Ensures the alter callbacks work properly. | ||
| ComponentRenderTest::testRenderEmbedWithNested | public | function | Render a card with slots that include a CTA component. | ||
| ComponentRenderTest::testRenderEmptyProps | public | function | Ensure that components can have 0 props. | ||
| ComponentRenderTest::testRenderIncludeDataMapping | public | function | Check using a component with an include and no default context. | ||
| ComponentRenderTest::testRenderIncludeDefaultContent | public | function | Check using a component with an include and default context. | ||
| ComponentRenderTest::testRenderInvalidSlot | public | function | Ensure that the slots throw an error for invalid slots. | ||
| ComponentRenderTest::testRenderLibraryOverrides | public | function | Check using the libraryOverrides. | ||
| ComponentRenderTest::testRenderNonExistingComponent | public | function | Ensures that including an invalid component creates an error. | ||
| ComponentRenderTest::testRenderPropValidation | public | function | Ensures the schema violations are reported properly. | ||
| ComponentRenderTest::testRenderSlots | public | function | Ensure that the slots allow a render array or a scalar when using the render element. | ||
| ComponentRenderTest::testVariants | public | function | Ensure that components variants render. | ||
| 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. | ||
| DrupalTestCaseTrait::checkErrorHandlerOnTearDown | public | function | Checks the test error handler after test execution. | ||
| ExpectDeprecationTrait::expectDeprecation | Deprecated | public | function | Adds an expected deprecation. | |
| ExpectDeprecationTrait::regularExpressionForFormatDescription | private | function | |||
| ExtensionListTestTrait::getModulePath | protected | function | Gets the path for the specified module. | ||
| ExtensionListTestTrait::getThemePath | protected | function | Gets the path for the specified theme. | ||
| KernelTestBase::$classLoader | protected | property | The class loader. | ||
| KernelTestBase::$configImporter | protected | property | The configuration importer. | ||
| KernelTestBase::$configSchemaCheckerExclusions | protected static | property | An array of config object names that are excluded from schema checking. | ||
| KernelTestBase::$container | protected | property | The test container. | ||
| KernelTestBase::$databasePrefix | protected | property | The test database prefix. | ||
| KernelTestBase::$keyValue | protected | property | The key_value service that must persist between container rebuilds. | ||
| KernelTestBase::$root | protected | property | The app root. | ||
| KernelTestBase::$siteDirectory | protected | property | The relative path to the test site directory. | ||
| KernelTestBase::$strictConfigSchema | protected | property | Set to TRUE to strict check all configuration saved. | ||
| KernelTestBase::$usesSuperUserAccessPolicy | protected | property | Set to TRUE to make user 1 a super user. | ||
| KernelTestBase::$vfsRoot | protected | property | The virtual filesystem root directory. | ||
| KernelTestBase::assertPostConditions | protected | function | |||
| KernelTestBase::bootEnvironment | protected | function | Bootstraps a basic test environment. | ||
| KernelTestBase::bootKernel | protected | function | Bootstraps a kernel for a test. | ||
| 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. | ||
| 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. | ||
| KernelTestBase::getDatabasePrefix | public | function | Gets the database prefix used for test isolation. | ||
| KernelTestBase::getExtensionsForModules | private | function | Returns Extension objects for $modules to install. | ||
| KernelTestBase::getModulesToEnable | protected 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 | |
| KernelTestBase::render | protected | function | Renders a render array. | ||
| KernelTestBase::setDebugDumpHandler | public static | function | Registers the dumper CLI handler when the DebugDump extension is enabled. | ||
| 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::setUpFilesystem | protected | function | Sets up the filesystem, so things like the file directory. | ||
| KernelTestBase::tearDown | protected | function | |||
| KernelTestBase::tearDownCloseDatabaseConnection | public | function | Additional tear down method to close the connection at the end. | ||
| KernelTestBase::vfsDump | protected | function | Dumps the current state of the virtual filesystem to STDOUT. | ||
| KernelTestBase::__construct | public | function | |||
| KernelTestBase::__sleep | public | function | Prevents serializing any properties. | ||
| 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. | ||
| 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. | ||
| 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. | ||
| StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. | ||
| 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.