You are here

public function EntityManagerTest::testGetBulkResourceUrlIsExternal in Acquia Content Hub 8

Test for getBulkResourceUrl() method, path is already external.

@covers ::getBulkResourceUrl

File

tests/src/Unit/EntityManagerTest.php, line 365

Class

EntityManagerTest
PHPUnit for the EntityManager class.

Namespace

Drupal\Tests\acquia_contenthub\Unit

Code

public function testGetBulkResourceUrlIsExternal() {
  $entity_manager = new EntityManager($this->loggerFactory, $this->configFactory, $this->clientManager, $this->contentHubEntitiesTracking, $this->entityTypeManager, $this->entityTypeBundleInfoManager, $this->kernel);
  $container = $this
    ->createMock('Drupal\\Core\\DependencyInjection\\Container');
  \Drupal::setContainer($container);
  $bulk_route_name = 'acquia_contenthub.acquia_contenthub_bulk_cdf';
  $url_options = [
    'option1' => 'option_value_1',
  ];
  $url_generator = $this
    ->createMock('Drupal\\Core\\Routing\\UrlGeneratorInterface');
  $url_generator
    ->method('generateFromRoute')
    ->with($bulk_route_name, $url_options)
    ->willReturn('http://localhost/node/1');
  $container
    ->expects($this
    ->once())
    ->method('get')
    ->with('url_generator')
    ->willReturn($url_generator);
  $this->settings
    ->expects($this
    ->once())
    ->method('get')
    ->with('rewrite_domain')
    ->willReturn('http://my-rewrite-domain.com');
  $result_url = $entity_manager
    ->getBulkResourceUrl($url_options);
  $expected_url = 'http://localhost/node/1';
  $this
    ->assertEquals($expected_url, $result_url);
}