class TextFieldRdfaTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/rdf/tests/src/Kernel/Field/TextFieldRdfaTest.php \Drupal\Tests\rdf\Kernel\Field\TextFieldRdfaTest
- 9 core/modules/rdf/tests/src/Kernel/Field/TextFieldRdfaTest.php \Drupal\Tests\rdf\Kernel\Field\TextFieldRdfaTest
Tests RDFa output by text field formatters.
@group rdf
Hierarchy
- class \Drupal\Tests\rdf\Kernel\Field\FieldRdfaTestBase extends \Drupal\Tests\field\Kernel\FieldKernelTestBase uses RdfParsingTrait
- class \Drupal\Tests\rdf\Kernel\Field\TextFieldRdfaTest
Expanded class hierarchy of TextFieldRdfaTest
File
- core/
modules/ rdf/ tests/ src/ Kernel/ Field/ TextFieldRdfaTest.php, line 12
Namespace
Drupal\Tests\rdf\Kernel\FieldView source
class TextFieldRdfaTest extends FieldRdfaTestBase {
/**
* {@inheritdoc}
*/
protected $fieldType = 'text';
/**
* The 'value' property value for testing.
*
* @var string
*/
protected $testValue = 'test_text_value';
/**
* The 'summary' property value for testing.
*
* @var string
*/
protected $testSummary = 'test_summary_value';
/**
* {@inheritdoc}
*/
protected static $modules = [
'text',
'filter',
];
protected function setUp() : void {
parent::setUp();
$this
->installConfig([
'filter',
]);
$this
->createTestField();
// Add the mapping.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
$mapping
->setFieldMapping($this->fieldName, [
'properties' => [
'schema:text',
],
])
->save();
// Set up test entity.
$this->entity = EntityTest::create();
$this->entity->{$this->fieldName}->value = $this->testValue;
$this->entity->{$this->fieldName}->summary = $this->testSummary;
}
/**
* Tests all formatters.
*
* @todo Check for the summary mapping.
*/
public function testAllFormatters() {
$formatted_value = strip_tags($this->entity->{$this->fieldName}->processed);
// Tests the default formatter.
$this
->assertFormatterRdfa([
'type' => 'text_default',
], 'http://schema.org/text', [
'value' => $formatted_value,
]);
// Tests the summary formatter.
$this
->assertFormatterRdfa([
'type' => 'text_summary_or_trimmed',
], 'http://schema.org/text', [
'value' => $formatted_value,
]);
// Tests the trimmed formatter.
$this
->assertFormatterRdfa([
'type' => 'text_trimmed',
], 'http://schema.org/text', [
'value' => $formatted_value,
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldRdfaTestBase:: |
protected | property | TRUE if verbose debugging is enabled. | |
FieldRdfaTestBase:: |
protected | property | The entity to render for testing. | |
FieldRdfaTestBase:: |
protected | property | The name of the field to create for testing. | |
FieldRdfaTestBase:: |
protected | property | The URI to identify the entity. | |
FieldRdfaTestBase:: |
protected | function | Helper function to test the formatter's RDFa. | |
FieldRdfaTestBase:: |
protected | function | Creates the field for testing. | |
FieldRdfaTestBase:: |
protected | function | Gets the absolute URI of an entity. | |
FieldRdfaTestBase:: |
protected | function | Parses a content and return the html element. | |
FieldRdfaTestBase:: |
protected | function | Performs an xpath search on a certain content. | |
RdfParsingTrait:: |
protected | function | Counts the number of resources of the provided type. | |
RdfParsingTrait:: |
protected | function | Gets type of RDF Element. | |
RdfParsingTrait:: |
protected | function | Checks if a html document contains a resource with a given property value. | |
RdfParsingTrait:: |
protected | function | Checks if a html document contains a resource with a given property value. | |
RdfParsingTrait:: |
protected | function | Checks if RDF Node property is blank. | |
TextFieldRdfaTest:: |
protected | property |
The machine name of the field type to test. Overrides FieldRdfaTestBase:: |
|
TextFieldRdfaTest:: |
protected static | property |
Modules to enable. Overrides FieldRdfaTestBase:: |
|
TextFieldRdfaTest:: |
protected | property | The 'summary' property value for testing. | |
TextFieldRdfaTest:: |
protected | property |
The 'value' property value for testing. Overrides FieldRdfaTestBase:: |
|
TextFieldRdfaTest:: |
protected | function | ||
TextFieldRdfaTest:: |
public | function | Tests all formatters. |