public function DateTest::testRenderItem in Views XML Backend 8
Same name in this branch
- 8 tests/src/Unit/Plugin/views/sort/DateTest.php \Drupal\Tests\views_xml_backend\Unit\Plugin\views\sort\DateTest::testRenderItem()
- 8 tests/src/Unit/Plugin/views/field/DateTest.php \Drupal\Tests\views_xml_backend\Unit\Plugin\views\field\DateTest::testRenderItem()
@covers ::render_item
File
- tests/
src/ Unit/ Plugin/ views/ field/ DateTest.php, line 26 - Contains \Drupal\Tests\views_xml_backend\Unit\Plugin\views\field\DateTest.
Class
- DateTest
- @coversDefaultClass \Drupal\views_xml_backend\Plugin\views\field\Date @group views_xml_backend
Namespace
Drupal\Tests\views_xml_backend\Unit\Plugin\views\fieldCode
public function testRenderItem() {
$date_formatter = $this
->prophesize(DateFormatterInterface::class);
$entity_storage = $this
->prophesize(EntityStorageInterface::class);
$date_formatter
->formatTimeDiffSince(strtotime('January 1, 2000'), [
'granularity' => 2,
])
->willReturn('1234')
->shouldBeCalled();
$plugin = new Date([], '', [], $date_formatter
->reveal(), $entity_storage
->reveal());
$plugin->field_alias = 'field_alias';
$options = [
'date_format' => 'raw time ago',
];
$plugin
->init($this
->getMockedView(), $this
->getMockedDisplay(), $options);
$this
->assertSame('1234', $plugin
->render_item(0, [
'value' => 'January 1, 2000',
]));
}