public function FieldTest::testTimestampFieldTokens in Token 8
Tests support for a timestamp fields.
File
- tests/
src/ Kernel/ FieldTest.php, line 748
Class
- FieldTest
- Tests field tokens.
Namespace
Drupal\Tests\token\KernelCode
public function testTimestampFieldTokens() {
$node = Node::create([
'title' => 'Node for timestamp field',
'type' => 'article',
]);
$node
->set('field_timestamp', [
'1277540209',
'1532593009',
])
->save();
$this
->assertTokens('node', [
'node' => $node,
], [
'field_timestamp:date:custom:Y' => '2010',
'field_timestamp:date:html_month' => '2010-06',
'field_timestamp:date' => $node
->get('field_timestamp')->value,
'field_timestamp:0:date:custom:Y' => '2010',
'field_timestamp:0:date:html_month' => '2010-06',
'field_timestamp:0:date' => $node
->get('field_timestamp')->value,
'field_timestamp:1:date:custom:Y' => '2018',
'field_timestamp:1:date:html_month' => '2018-07',
'field_timestamp:1:date' => $node
->get('field_timestamp')
->get(1)->value,
]);
}