public function AmpFormatterVideoTest::createAmpNode in Accelerated Mobile Pages (AMP) 8.3
Create a node with desired content for testing.
Overrides AmpTestBase::createAmpNode
File
- tests/
src/ Functional/ AmpFormatterVideoTest.php, line 65
Class
- AmpFormatterVideoTest
- Tests AMP Video Formatter.
Namespace
Drupal\Tests\amp\FunctionalCode
public function createAmpNode() {
parent::createAmpNode();
$file_system = \Drupal::service('file_system');
$source_path = 'https://amp.dev/static/samples/video/tokyo.mp4';
$video_path = system_retrieve_file($source_path, PublicStream::basePath());
$file = File::create([
'uri' => $video_path,
]);
$file
->save();
// Create a new node with video attached.
$this->node
->set($this->fieldName, [
'target_id' => $file
->id(),
])
->save();
// Test subparts of markup to avoid failures due to line breaks.
$file_path = $file
->createFileUrl();
$this->valuesOut = [
'<amp-video',
'src="' . $file_path . '"',
'<div fallback>',
'<p>Your browser doesn’t support HTML5 video</p>',
'</div>',
'</amp-video>',
];
}