You are here

public function StaticGeneratorTest::testPagers in Tome 8

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

File

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

Class

StaticGeneratorTest
Tests that static site generation works.

Namespace

Drupal\Tests\tome_static\Kernel

Code

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

  /** @var \Drupal\tome_static\StaticGenerator $static */
  $static = \Drupal::service('tome_static.generator');
  $invoke_paths = $static
    ->requestPath('/tome-test/pager-page');
  $this
    ->assertContains('/tome-test/pager-page?page=0', $invoke_paths);
  $this
    ->assertContains('/tome-test/pager-page?page=1', $invoke_paths);
  $this
    ->assertContains('/foobar?page=2', $invoke_paths);
  $base_dir = Settings::get('tome_static_directory');
  $contents = file_get_contents("{$base_dir}/tome-test/pager-page/index.html");
  $this
    ->assertStringContainsString('href="/tome-test/pager-page"', $contents);
  $this
    ->assertStringContainsString('href="/tome-test/pager-page/page/2"', $contents);
  $this
    ->assertStringContainsString('href="/foobar/page/3"', $contents);
}