Skip to content

Commit

Permalink
Merge pull request #275 from openeuropa/OEL-1863
Browse files Browse the repository at this point in the history
OEL-1863: Added file assert for PersonContentRenderTest.
  • Loading branch information
tibi2303 authored Jun 2, 2024
2 parents 1a0dbeb + 4883bbd commit 1e7e7b8
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions tests/src/Functional/PersonContentRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\media\Entity\Media;
use Drupal\node\NodeInterface;
use Drupal\Tests\media\Traits\MediaTypeCreationTrait;
use Drupal\Tests\oe_bootstrap_theme\PatternAssertion\FilePatternAssert;
use Drupal\Tests\TestFileCreationTrait;
use Symfony\Component\DomCrawler\Crawler;

Expand Down Expand Up @@ -143,13 +144,29 @@ public function testPersonPage(): void {

$document_group_title = $content->filter('h3.fs-4');
$this->assertEquals('Curriculum Vitae', $document_group_title->text());
$files = $content->filter('.bcl-file');
$this->assertEquals(
'Person document test',
$files->filter('p')->text()
);
$files = $content->filter('.bcl-file-container');

$document_file = File::create([
'uri' => $this->getTestFiles('text')[0]->uri,
]);
$document_file->save();
$expected_document = [
'file' => [
'title' => 'Person document test',
'language' => 'English',
'meta' => '(1 KB - TXT)',
'icon' => 'file-text-fill',
'url' => $document_file->createFileUrl(FALSE),
],
'translations' => NULL,
'link_label' => 'Download',
];
$this->assertCount(3, $files);
$assert = new FilePatternAssert();
foreach ($files as $index => $file) {
$file = $files->eq($index);
$assert->assertPattern($expected_document, $file->outerHtml());
}
}

/**
Expand Down

0 comments on commit 1e7e7b8

Please sign in to comment.