FieldRdfaDatatypeCallbackTest.php in Drupal 9        
                          
                  
                        
  
  
  
  
File
  core/modules/rdf/tests/src/Kernel/Field/FieldRdfaDatatypeCallbackTest.php
  
    View source  
  <?php
namespace Drupal\Tests\rdf\Kernel\Field;
use Drupal\entity_test\Entity\EntityTest;
class FieldRdfaDatatypeCallbackTest extends FieldRdfaTestBase {
  
  protected $fieldType = 'text';
  
  protected static $modules = [
    'text',
    'filter',
    'rdf_test',
  ];
  protected function setUp() : void {
    parent::setUp();
    $this
      ->createTestField();
    $this
      ->installConfig([
      'filter',
    ]);
    
    $mapping = rdf_get_mapping('entity_test', 'entity_test');
    $mapping
      ->setFieldMapping($this->fieldName, [
      'properties' => [
        'schema:interactionCount',
      ],
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf_test\\TestDataConverter::convertFoo',
      ],
    ])
      ->save();
    
    $this->testValue = $this
      ->randomMachineName();
    $this->entity = EntityTest::create();
    $this->entity->{$this->fieldName}->value = $this->testValue;
    $this->entity
      ->save();
    $this->uri = $this
      ->getAbsoluteUri($this->entity);
  }
  
  public function testDefaultFormatter() {
    
    $this
      ->assertFormatterRdfa([
      'type' => 'text_default',
    ], 'http://schema.org/interactionCount', [
      'value' => 'foo' . $this->testValue,
    ]);
  }
}