setProvider example


  public function testGetProvider() {
    $plugin = new Plugin(['provider' => 'example']);
    $this->assertEquals('example', $plugin->getProvider());
  }

  /** * @covers ::setProvider */
  public function testSetProvider() {
    $plugin = new Plugin([]);
    $plugin->setProvider('example');
    $this->assertEquals('example', $plugin->getProvider());
  }

  /** * @covers ::getId */
  public function testGetId() {
    $plugin = new Plugin(['id' => 'example']);
    $this->assertEquals('example', $plugin->getId());
  }

  

class AnnotationBaseTest extends TestCase {

  /** * @covers ::getProvider * @covers ::setProvider */
  public function testSetProvider() {
    $plugin = new AnnotationBaseStub();
    $plugin->setProvider('example');
    $this->assertEquals('example', $plugin->getProvider());
  }

  /** * @covers ::getId */
  public function testGetId() {
    $plugin = new AnnotationBaseStub();
    // Doctrine sets the public prop directly.     $plugin->id = 'example';
    $this->assertEquals('example', $plugin->getId());
  }
$endpoint_url = Url::fromRoute('media_test_oembed.resource.get')
      ->setAbsolute()
      ->toString();

    /** @var \Drupal\media_test_oembed\ProviderRepository $provider_repository */
    $provider_repository = $this->container->get('media.oembed.provider_repository');

    foreach ($providers as &$provider) {
      foreach ($provider['endpoints'] as &$endpoint) {
        $endpoint['url'] = $endpoint_url;
      }
      $provider_repository->setProvider(
        new Provider($provider['provider_name']$provider['provider_url']$provider['endpoints'])
      );
    }
  }

}
/** * Tests updating a shared table field definition. */
  public function testOnFieldStorageDefinitionUpdateShared() {
    // Install the test entity type with an additional field. Use a multi-column     // field so that field name and column name(s) do not match.     $field = BaseFieldDefinition::create('shape')
      // Avoid creating a foreign key which is irrelevant for this test.       ->setSetting('foreign_key_name', NULL)
      ->setName('shape')
      ->setProvider('entity_test');
    $this->state->set('entity_test.additional_base_field_definitions', [
      'shape' => $field,
    ]);
    $this->entityDefinitionUpdateManager->installFieldStorageDefinition(
      'shape',
      'entity_test',
      'entity_test',
      $field
    );

    // Make sure the field is not marked as NOT NULL initially.
$field->setRevisionable(TRUE);
        }
        if ($entity_type->isTranslatable()) {
          $field->setTranslatable(TRUE);
        }
        break;
    }

    $field
      ->setName($field_name)
      ->setTargetEntityTypeId($entity_type_id)
      ->setProvider($entity_type->getProvider());

    // Build up a map of expected primary keys depending on the entity type     // configuration.     $id_key = $entity_type->getKey('id');
    $revision_key = $entity_type->getKey('revision');
    $langcode_key = $entity_type->getKey('langcode');

    $expected = [];
    $expected[$entity_type->getBaseTable()] = [$id_key];
    if ($entity_type->isRevisionable()) {
      $expected[$entity_type->getRevisionTable()] = [$revision_key];
    }

    return $this->annotationReader;
  }

  /** * {@inheritdoc} */
  protected function prepareAnnotationDefinition(AnnotationInterface $annotation$class) {
    parent::prepareAnnotationDefinition($annotation$class);

    if (!$annotation->getProvider()) {
      $annotation->setProvider($this->getProviderFromNamespace($class));
    }
  }

  /** * Extracts the provider name from a Drupal namespace. * * @param string $namespace * The namespace to extract the provider from. * * @return string|null * The matching provider name, or NULL otherwise. */

  public function testGetFieldStorageDefinitions() {
    $field_definition = $this->setUpEntityWithFieldDefinition(TRUE);
    $field_storage_definition = $this->prophesize(FieldStorageDefinitionInterface::class);
    $field_storage_definition->getName()->willReturn('field_storage');

    $base_field_definition = $this->prophesize(BaseFieldDefinition::class);
    $base_field_definition->setProvider('example_module')->shouldBeCalled();
    $base_field_definition->setName('base_field')->shouldBeCalled();
    $base_field_definition->setTargetEntityTypeId('test_entity_type')->shouldBeCalled();

    $definitions = [
      'base_field' => $base_field_definition->reveal(),
      'field_storage' => $field_storage_definition->reveal(),
    ];

    $this->moduleHandler->invokeAllWith('entity_base_field_info', Argument::any());
    $this->moduleHandler->invokeAllWith('entity_field_storage_info', Argument::any())
      ->will(function D$arguments) use ($definitions) {
        [

  public static function createFromFieldStorageDefinition(FieldStorageDefinitionInterface $definition) {
    return static::create($definition->getType())
      ->setCardinality($definition->getCardinality())
      ->setConstraints($definition->getConstraints())
      ->setCustomStorage($definition->hasCustomStorage())
      ->setDescription($definition->getDescription())
      ->setLabel($definition->getLabel())
      ->setName($definition->getName())
      ->setProvider($definition->getProvider())
      ->setRevisionable($definition->isRevisionable())
      ->setSettings($definition->getSettings())
      ->setTargetEntityTypeId($definition->getTargetEntityTypeId())
      ->setTranslatable($definition->isTranslatable());
  }

  /** * {@inheritdoc} */
  public static function createFromItemType($item_type) {
    // The data type of a field item is in the form of "field_item:$field_type".
/** * {@inheritdoc} */
  public function installFieldableEntityType(EntityTypeInterface $entity_type, array $field_storage_definitions) {
    $this->clearCachedDefinitions();
    foreach ($field_storage_definitions as $name => $field_storage_definition) {
      if ($field_storage_definition instanceof BaseFieldDefinition) {
        $field_storage_definition
          ->setName($name)
          ->setTargetEntityTypeId($entity_type->id())
          ->setProvider($entity_type->getProvider())
          ->setTargetBundle(NULL);
      }
    }
    $this->entityTypeListener->onFieldableEntityTypeCreate($entity_type$field_storage_definitions);
  }

  /** * {@inheritdoc} */
  public function updateFieldableEntityType(EntityTypeInterface $entity_type, array $field_storage_definitions, array &$sandbox = NULL) {
    $original = $this->getEntityType($entity_type->id());

    
->setReadOnly(TRUE)
        ->setRevisionable(TRUE)
        ->setTranslatable(TRUE);
    }

    // Assign base field definitions the entity type provider.     $provider = $entity_type->getProvider();
    foreach ($base_field_definitions as $definition) {
      // @todo Remove this check once FieldDefinitionInterface exposes a proper       // provider setter. See https://www.drupal.org/node/2225961.       if ($definition instanceof BaseFieldDefinition) {
        $definition->setProvider($provider);
      }
    }

    // Retrieve base field definitions from modules.     $this->moduleHandler->invokeAllWith(
      'entity_base_field_info',
      function Dcallable $hook, string $module) use (&$base_field_definitions$entity_type) {
        $module_definitions = $hook($entity_type) ?? [];
        // Ensure the provider key actually matches the name of the provider         // defining the field.         foreach ($module_definitions as $field_name => $definition) {
          


  /** * Tests provider. * * @covers ::getProvider * @covers ::setProvider */
  public function testFieldProvider() {
    $definition = BaseFieldDefinition::create($this->fieldType);
    $provider = $this->randomMachineName();
    $definition->setProvider($provider);
    $this->assertEquals($provider$definition->getProvider());
  }

  /** * Tests custom storage. * * @covers ::hasCustomStorage * @covers ::setCustomStorage */
  public function testCustomStorage() {
    $definition = BaseFieldDefinition::create($this->fieldType);
    
// Assert plugin starts empty.     $plugin = new PluginID();
    $this->assertEquals([
      'id' => NULL,
      'class' => NULL,
      'provider' => NULL,
    ]$plugin->get());

    // Set values and ensure we can retrieve them.     $plugin->value = 'foo';
    $plugin->setClass('bar');
    $plugin->setProvider('baz');
    $this->assertEquals([
      'id' => 'foo',
      'class' => 'bar',
      'provider' => 'baz',
    ]$plugin->get());
  }

  /** * @covers ::getId */
  public function testGetId() {
    
Home | Imprint | This part of the site doesn't use cookies.