Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OEL-1863: Added file assert for PersonContentRenderTest. #275

Merged
merged 7 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"enable-patching": true,
"patches": {
"openeuropa/oe_bootstrap_theme": {
"development": "https://github.com/openeuropa/oe_bootstrap_theme/compare/1.10.0...1.x.diff"
"file pattern assert fix": "https://github.com/openeuropa/oe_bootstrap_theme/compare/1.10.0...OEL-1863.diff"
}
},
"artifacts": {
Expand Down
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