コード例 #1
0
 /**
  * Tests the toUrl() method with the 'revision' link template.
  *
  * @param bool $has_bundle_key
  *   Whether or not the mock entity type should have a bundle key.
  * @param string|null $bundle_entity_type
  *   The ID of the bundle entity type of the mock entity type, or NULL if the
  *   mock entity type should not have a bundle entity type.
  * @param string $bundle_key
  *   The bundle key of the mock entity type or FALSE if the entity type should
  *   not have a bundle key.
  * @param array $expected_route_parameters
  *   The expected route parameters of the generated URL.
  *
  * @dataProvider providerTestToUrlLinkTemplateAddForm
  *
  * @covers ::toUrl
  * @covers ::linkTemplates
  * @covers ::urlRouteParameters
  */
 public function testToUrlLinkTemplateAddForm($has_bundle_key, $bundle_entity_type, $bundle_key, $expected_route_parameters)
 {
     $values = ['id' => $this->entityId, 'langcode' => $this->langcode];
     $entity = $this->getEntity(Entity::class, $values);
     $this->entityType->hasKey('bundle')->willReturn($has_bundle_key);
     $this->entityType->getBundleEntityType()->willReturn($bundle_entity_type);
     $this->entityType->getKey('bundle')->willReturn($bundle_key);
     $link_template = 'add-form';
     $this->registerLinkTemplate($link_template);
     /** @var \Drupal\Core\Url $url */
     $url = $entity->toUrl($link_template);
     $this->assertUrl('entity.test_entity.add_form', $expected_route_parameters, $entity, FALSE, $url);
 }