function AnnounceRendererTest::testRendererContent
Same name in other branches
- 11.x core/modules/announcements_feed/tests/src/Kernel/AnnounceRendererTest.php \Drupal\Tests\announcements_feed\Kernel\AnnounceRendererTest::testRendererContent()
Tests rendered valid content.
File
-
core/
modules/ announcements_feed/ tests/ src/ Kernel/ AnnounceRendererTest.php, line 31
Class
- AnnounceRendererTest
- @coversDefaultClass \Drupal\announcements_feed\AnnounceRenderer
Namespace
Drupal\Tests\announcements_feed\KernelCode
public function testRendererContent() : void {
$feed_item_1 = [
'id' => '1001',
'content_html' => 'Test teaser 1',
'url' => 'https://www.drupal.org/project/announce',
'_drupalorg' => [
'featured' => TRUE,
'version' => '^10||^11',
],
'date_modified' => "2021-09-02T15:09:42+00:00",
'date_published' => "2021-09-01T15:09:42+00:00",
];
$feed_item_2 = [
'id' => '1002',
'content_html' => 'Test teaser 1',
'url' => 'https://www.drupal.org/project/announce',
'_drupalorg' => [
'featured' => FALSE,
'version' => '^10||^11',
],
'date_modified' => "2021-09-02T15:09:42+00:00",
'date_published' => "2021-09-01T15:09:42+00:00",
];
$this->setFeedItems([
$feed_item_1,
$feed_item_2,
]);
$render = $this->container
->get('announcements_feed.renderer')
->render();
$this->assertEquals('announcements_feed', $render['#theme']);
$this->assertEquals(1, $render['#count']);
$this->assertEquals(1001, $render['#featured'][0]->id);
$render = $this->container
->get('announcements_feed.renderer')
->render();
$this->assertEquals('announcements_feed', $render['#theme']);
$this->assertEquals(1, $render['#count']);
$this->assertEquals(1002, $render['#standard'][0]->id);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.