You are here

protected function FreelinkingFilterTest::setUp in Freelinking 8.3

Same name and namespace in other branches
  1. 4.0.x tests/src/Functional/FreelinkingFilterTest.php \Drupal\Tests\freelinking\Functional\FreelinkingFilterTest::setUp()

Overrides FreelinkingBrowserTestBase::setUp

File

tests/src/Functional/FreelinkingFilterTest.php, line 20

Class

FreelinkingFilterTest
Tests that freelinking filter is functional.

Namespace

Drupal\Tests\freelinking\Functional

Code

protected function setUp() {
  parent::setUp();

  /** @var \Drupal\Core\File\FileSystemInterface $filesystem */
  $filesystem = $this->container
    ->get('file_system');

  // Make sure that freelinking filter is activated.
  $this
    ->updateFilterSettings();

  // Create a third freelinking page, which will not be freelinked.
  $this
    ->drupalCreateNode([
    'type' => 'page',
    'title' => t('Third page'),
  ]);
  $this
    ->createPathAlias('/node/3', '/third-page');

  // Upload Drupal logo to files directory to test file and image plugins.
  $root_path = $_SERVER['DOCUMENT_ROOT'];
  $image_path = 'core/themes/bartik/logo.svg';
  $filesystem
    ->copy($image_path, 'public://logo.svg');
  $image = File::create([
    'uri' => 'public://logo.svg',
    'status' => FILE_STATUS_PERMANENT,
  ]);
  $image
    ->save();
  $this
    ->assertTrue(is_string($filesystem
    ->realpath('public://logo.svg')), t('Image @image was saved successfully', [
    '@image' => 'public://logo.svg',
  ]));
}