You are here

public function StaticGeneratorTest::testOembed in Tome 8

@covers \Drupal\tome_static\EventSubscriber\MediaOembedPathSubscriber::modifyDestination @covers \Drupal\tome_static\EventSubscriber\MediaOembedPathSubscriber::modifyHtml @covers \Drupal\tome_static\EventSubscriber\MediaOembedPathSubscriber::modifyUrl

File

modules/tome_static/tests/src/Kernel/StaticGeneratorTest.php, line 268

Class

StaticGeneratorTest
Tests that static site generation works.

Namespace

Drupal\Tests\tome_static\Kernel

Code

public function testOembed() {
  $this
    ->enableModules([
    'tome_test',
  ]);

  /** @var \Drupal\tome_static\StaticGenerator $static */
  $static = \Drupal::service('tome_static.generator');
  $invoke_paths = $static
    ->requestPath('/tome-test/oembed-page');
  $query = 'url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Duqmq5FBP_T0&max_width=0&max_height=0&hash=ON_e21QvgL9euuUSW2TP_s1x62ZmFzzZNuIHbsQpXNg';
  $this
    ->assertContains("/media/oembed?{$query}", $invoke_paths);
  $request_paths = $static
    ->exportPaths($invoke_paths);
  $this
    ->assertContains("/media/oembed?{$query}", $request_paths);
  $static
    ->requestPath("/media/oembed?{$query}");
  $base_dir = Settings::get('tome_static_directory');
  $modified_path = "/media/oembed/" . md5(urldecode($query));
  $contents = file_get_contents("{$base_dir}/tome-test/oembed-page/index.html");
  $this
    ->assertStringContainsString("src='{$modified_path}'", $contents);
  $this
    ->assertFileExists("{$base_dir}/{$modified_path}" . '/index.html');
}