public function PublicationDateNodeFormTest::testNodeForm in Publication Date 8.2
File
- tests/
src/ Functional/ PublicationDateNodeFormTest.php, line 73
Class
- PublicationDateNodeFormTest
- Tests the integration on node forms.
Namespace
Drupal\Tests\publication_date\FunctionalCode
public function testNodeForm() {
// Unpublished by default
$title = $this
->randomString() . '1';
$this
->drupalGet(Url::fromRoute('node.add', [
'node_type' => 'test1',
]));
$this
->assertSession()
->fieldValueEquals('published_at[0][value][date]', '');
$this
->assertSession()
->fieldValueEquals('published_at[0][value][time]', '');
$this
->getSession()
->getPage()
->fillField('title[0][value]', $title);
$this
->getSession()
->getPage()
->findButton('Save')
->submit();
$node = $this
->getNodeByTitle($title);
$this
->assertEquals($node->published_at->value, PUBLICATION_DATE_DEFAULT);
// Published by default
$title = $this
->randomString() . '2';
$this
->drupalGet(Url::fromRoute('node.add', [
'node_type' => 'test2',
]));
$this
->assertSession()
->fieldValueEquals('published_at[0][value][date]', '');
$this
->assertSession()
->fieldValueEquals('published_at[0][value][time]', '');
$this
->getSession()
->getPage()
->fillField('title[0][value]', $title);
$this
->getSession()
->getPage()
->findButton('Save')
->submit();
$node = $this
->getNodeByTitle($title);
$this
->assertNotEmpty($node->published_at->value);
$this
->assertNotEquals($node->published_at->value, PUBLICATION_DATE_DEFAULT);
}