You are here

class StringFieldRdfaTest in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rdf/tests/src/Kernel/Field/StringFieldRdfaTest.php \Drupal\Tests\rdf\Kernel\Field\StringFieldRdfaTest
  2. 9 core/modules/rdf/tests/src/Kernel/Field/StringFieldRdfaTest.php \Drupal\Tests\rdf\Kernel\Field\StringFieldRdfaTest

Tests RDFa output by text field formatters.

@group rdf

Hierarchy

Expanded class hierarchy of StringFieldRdfaTest

File

core/modules/rdf/tests/src/Kernel/Field/StringFieldRdfaTest.php, line 12

Namespace

Drupal\Tests\rdf\Kernel\Field
View source
class StringFieldRdfaTest extends FieldRdfaTestBase {

  /**
   * {@inheritdoc}
   */
  protected $fieldType = 'string';

  /**
   * 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';
  protected function setUp() : void {
    parent::setUp();
    $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 string formatters.
   */
  public function testStringFormatters() {

    // Tests the string formatter.
    $this
      ->assertFormatterRdfa([
      'type' => 'string',
    ], 'http://schema.org/text', [
      'value' => $this->testValue,
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FieldRdfaTestBase::$debug protected property TRUE if verbose debugging is enabled.
FieldRdfaTestBase::$entity protected property The entity to render for testing.
FieldRdfaTestBase::$fieldName protected property The name of the field to create for testing.
FieldRdfaTestBase::$modules protected static property Modules to enable.
FieldRdfaTestBase::$uri protected property The URI to identify the entity.
FieldRdfaTestBase::assertFormatterRdfa protected function Helper function to test the formatter's RDFa.
FieldRdfaTestBase::createTestField protected function Creates the field for testing.
FieldRdfaTestBase::getAbsoluteUri protected function Gets the absolute URI of an entity.
FieldRdfaTestBase::parseContent protected function Parses a content and return the html element.
FieldRdfaTestBase::xpathContent protected function Performs an xpath search on a certain content.
RdfParsingTrait::getElementByRdfTypeCount protected function Counts the number of resources of the provided type.
RdfParsingTrait::getElementRdfType protected function Gets type of RDF Element.
RdfParsingTrait::hasRdfChildProperty protected function Checks if a html document contains a resource with a given property value.
RdfParsingTrait::hasRdfProperty protected function Checks if a html document contains a resource with a given property value.
RdfParsingTrait::rdfElementIsBlankNode protected function Checks if RDF Node property is blank.
StringFieldRdfaTest::$fieldType protected property The machine name of the field type to test. Overrides FieldRdfaTestBase::$fieldType
StringFieldRdfaTest::$testSummary protected property The 'summary' property value for testing.
StringFieldRdfaTest::$testValue protected property The 'value' property value for testing. Overrides FieldRdfaTestBase::$testValue
StringFieldRdfaTest::setUp protected function
StringFieldRdfaTest::testStringFormatters public function Tests string formatters.