Skip to content

Commit

Permalink
Merge pull request #624 from openeuropa/EWPP-4414
Browse files Browse the repository at this point in the history
EWPP-4414: Use mock external page for tests.
  • Loading branch information
imanoleguskiza authored Jun 11, 2024
2 parents 59c42d6 + b71c4cb commit 9805f70
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\oe_content_persistent_test\EventSubscriber;

Expand All @@ -26,7 +26,7 @@ public function testResolver(PersistentUrlResolverEvent $event): void {
}

if ($entity->label() === 'External') {
$event->setUrl(Url::fromUri('https://commission.europa.eu/index_en'));
$event->setUrl(Url::fromUri('http://web:8080/tests/fixtures/example.html'));
}

if ($entity->label() === 'Early render') {
Expand All @@ -37,7 +37,7 @@ public function testResolver(PersistentUrlResolverEvent $event): void {
],
];
\Drupal::service('renderer')->render($render);
$event->setUrl(Url::fromUri('https://commission.europa.eu/index_en'));
$event->setUrl(Url::fromUri('http://web:8080/tests/fixtures/example.html'));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\Tests\oe_content_persistent\Functional;

Expand Down Expand Up @@ -106,7 +106,7 @@ public function testPersistentUrlController(): void {
$node->save();
$this->drupalGet('/content/' . $node->uuid());
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->addressEquals('https://commission.europa.eu/index_en');
$this->assertSession()->addressEquals('http://web:8080/tests/fixtures/example.html');

\Drupal::entityTypeManager()->getStorage('node')->resetCache();
$node = \Drupal::service('entity_type.manager')->getStorage('node')->load($node->id());
Expand All @@ -116,7 +116,7 @@ public function testPersistentUrlController(): void {
$node->save();
$this->drupalGet('/content/' . $node->uuid());
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->addressEquals('https://commission.europa.eu/index_en');
$this->assertSession()->addressEquals('http://web:8080/tests/fixtures/example.html');

// Try to get not existing entity.
$this->drupalGet('/content/' . \Drupal::service('uuid')->generate());
Expand Down
11 changes: 11 additions & 0 deletions tests/fixtures/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<body>

<h1>Example Heading</h1>

<p>Example paragraph.</p>

</body>
</html>

0 comments on commit 9805f70

Please sign in to comment.