public function KickerFormatterTest::testKickerFormatter in Facebook Instant Articles 3.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/Plugin/Field/FieldFormatter/KickerFormatterTest.php \Drupal\Tests\fb_instant_articles\Kernel\Plugin\Field\FieldFormatter\KickerFormatterTest::testKickerFormatter()
Test the instant article kicker formatter.
File
- tests/
src/ Kernel/ Plugin/ Field/ FieldFormatter/ KickerFormatterTest.php, line 33
Class
- KickerFormatterTest
- Tests the KickerFormatter.
Namespace
Drupal\Tests\fb_instant_articles\Kernel\Plugin\Field\FieldFormatterCode
public function testKickerFormatter() {
$value_alpha = 'Here is some kicker test. Wonder why they call it a kicker?';
$value_beta = 'Another kicker, which should never be seen.';
$entity = EntityTest::create([]);
$entity->{$this->fieldName}[] = [
'value' => $value_alpha,
];
$entity->{$this->fieldName}[] = [
'value' => $value_beta,
];
/** @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_HEADER, $this->normalizerMock);
$this
->assertEquals($value_alpha, $article
->getHeader()
->getKicker()
->getPlainText());
}