public function AmpFormatterImageCarouselTest::createAmpNode in Accelerated Mobile Pages (AMP) 8.3
Create a node with desired content for testing.
Overrides AmpTestBase::createAmpNode
File
- tests/
src/ Functional/ AmpFormatterImageCarouselTest.php, line 69
Class
- AmpFormatterImageCarouselTest
- Tests AMP Image Carousel formatter.
Namespace
Drupal\Tests\amp\FunctionalCode
public function createAmpNode() {
// Create a node with an image to test AMP image formatter.
parent::createAmpNode();
$images = $this
->getTestFiles('image');
$image = array_pop($images);
$file = File::create([
'uri' => $image->uri,
]);
$file
->save();
// Create a new node with an image attached.
$this->node
->set($this->fieldName, [
'target_id' => $file
->id(),
'alt' => 'alt text',
])
->save();
// Test subparts of markup to avoid failures due to line breaks.
$file_path = $file
->createFileUrl();
$this->valuesOut = [
'<amp-img layout="responsive" width="16" height="9" src="' . $file_path . '" alt="alt text">',
'</amp-img>',
];
$this
->drupalGet($file_path);
}