public function ParagraphFormatterTest::testParagraphFormatter in Facebook Instant Articles 8.2
Same name and namespace in other branches
- 3.x tests/src/Kernel/Plugin/Field/FieldFormatter/ParagraphFormatterTest.php \Drupal\Tests\fb_instant_articles\Kernel\Plugin\Field\FieldFormatter\ParagraphFormatterTest::testParagraphFormatter()
Test the instant article paragraph formatter.
File
- tests/
src/ Kernel/ Plugin/ Field/ FieldFormatter/ ParagraphFormatterTest.php, line 33
Class
- ParagraphFormatterTest
- Tests the instant article paragraph field formatter.
Namespace
Drupal\Tests\fb_instant_articles\Kernel\Plugin\Field\FieldFormatterCode
public function testParagraphFormatter() {
$value = 'I am a random value.';
$entity = EntityTest::create([]);
$entity->{$this->fieldName}->value = $value;
/** @var \Drupal\fb_instant_articles\Plugin\Field\InstantArticleFormatterInterface $formatter */
$formatter = $this->display
->getRenderer($this->fieldName);
$article = InstantArticle::create();
$formatter
->viewInstantArticle($entity->{$this->fieldName}, $article, Regions::REGION_CONTENT, $this->normalizerMock);
$children = $article
->getChildren();
$this
->assertEquals(1, count($children));
$this
->assertTrue($children[0] instanceof Paragraph);
}