public function LinkIframeFormatterTest::testFormatter in Link iframe formatter 8
Same name and namespace in other branches
- 2.x tests/src/Functional/LinkIframeFormatterTest.php \Drupal\Tests\link_iframe_formatter\Functional\LinkIframeFormatterTest::testFormatter()
Tests formatter.
File
- tests/
src/ Functional/ LinkIframeFormatterTest.php, line 73
Class
- LinkIframeFormatterTest
- Defines a class for testing link iframe formatter.
Namespace
Drupal\Tests\link_iframe_formatter\FunctionalCode
public function testFormatter() : void {
$this
->drupalLogin($this
->createUser([
'access content',
'view test entity',
]));
$url = sprintf('https://%s.com/index.html', $this
->randomMachineName());
$entity = EntityTest::create([
'name' => $this
->randomMachineName(),
'type' => 'entity_test',
'link' => [
'uri' => $url,
],
]);
$entity
->save();
$this
->drupalGet($entity
->toUrl());
$iframe = $this
->assertSession()
->elementExists('css', sprintf('iframe[src="%s"]', $url));
$this
->assertEquals(270, $iframe
->getAttribute('height'));
$this
->assertEquals(350, $iframe
->getAttribute('width'));
$this
->assertEquals('some-class', $iframe
->getAttribute('class'));
$link = $this
->assertSession()
->elementExists('named', [
'link',
$url,
]);
$this
->assertEquals($url, $link
->getAttribute('href'));
$this
->assertSession()
->pageTextContains('You may view the original link at');
}