protected function EmbeddedScheduledUpdateTypeTestBase::createNodeWithUpdate in Scheduled Updates 8
Parameters
string $title:
string $date_offset:
string $bundle:
string $reference_field_label:
string $reference_field_name:
bool $field_hidden:
Return value
Throws
\Behat\Mink\Exception\DriverException
\Behat\Mink\Exception\ElementNotFoundException
\Behat\Mink\Exception\ExpectationException
\Behat\Mink\Exception\ResponseTextException
\Behat\Mink\Exception\UnsupportedDriverActionException
2 calls to EmbeddedScheduledUpdateTypeTestBase::createNodeWithUpdate()
- EmbeddedScheduledUpdateTypeTestBase::checkRunningPromoteUpdates in tests/
src/ FunctionalJavascript/ EmbeddedScheduledUpdateTypeTestBase.php - Checking adding and running updates for title.
- EmbeddedScheduledUpdateTypeTestBase::checkRunningTitleUpdates in tests/
src/ FunctionalJavascript/ EmbeddedScheduledUpdateTypeTestBase.php - Checking adding and running updates for title.
File
- tests/
src/ FunctionalJavascript/ EmbeddedScheduledUpdateTypeTestBase.php, line 338 - Contains \Drupal\Tests\scheduled_updates\EmbeddedScheduledUpdateTypeTestBase.
Class
- EmbeddedScheduledUpdateTypeTestBase
- Base test class for embedded update types.
Namespace
Drupal\Tests\scheduled_updates\FunctionalJavascriptCode
protected function createNodeWithUpdate($title, $date_offset, $bundle, $reference_field_name, $reference_field_label, $field_hidden = FALSE) {
$page = $this
->getSession()
->getPage();
$id_field_name = str_replace('_', '-', $reference_field_name);
$entity_add_url = $this
->getEntityAddURL('node', $bundle);
$this
->drupalGet($entity_add_url);
$ief_button = "Add new {$reference_field_label}";
$this
->assertSession()
->buttonExists($ief_button);
// Open IEF form
$this
->submitIEFForm($ief_button, "edit-{$id_field_name}-actions-ief-add");
// Check opened form.
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertSession()
->pageTextContains('Update Date/time');
// Submit IEF form
// Create ief_test_complex node.
$page
->fillField("{$reference_field_name}[form][0][update_timestamp][0][value][date]", $this
->getRelativeDate($date_offset, 'm/d/Y'));
$page
->fillField("{$reference_field_name}[form][0][update_timestamp][0][value][time]", '01:00:00AM');
if ($field_hidden) {
// $inputs = $this->getSession()->getDriver()->find("(//html//form)");
// foreach ($inputs as $element) {
// echo "====== Found: " . PHP_EOL . $element->getOuterHtml() . PHP_EOL . PHP_EOL;
// }
// Hard-coded for now. @todo Create parameter to this function.
// promote_reference[form][inline_entity_form][field_promote][value]
$ief_field_name = "{$reference_field_name}[form][0][field_promote][value]";
//($ief_field_name, NULL, "$reference_field_name - hides update field");
$this
->assertSession()
->fieldNotExists($ief_field_name);
}
else {
// Hard-coded for now. @todo Create parameter to this function.
$ief_field_name = "{$reference_field_name}[form][0][field_title][0][value]";
$this
->assertSession()
->fieldExists($ief_field_name);
$page
->fillField($ief_field_name, "{$title}:updated");
}
$page
->pressButton("Create {$reference_field_label}");
// Edit button appears when saved.
// 'Saving IEF Update was successful.';
$this
->assertNotEmpty($this
->assertSession()
->waitForElementVisible('css', "[data-drupal-selector='edit-{$id_field_name}-entities-0-actions-ief-entity-edit']"));
// Create ief_test_complex node.
$edit = [
'title[0][value]' => $title,
];
$this
->drupalPostForm(NULL, $edit, t(static::NODE_SAVE_BUTTON_TEXT));
// 'Saving parent entity was successful.'
$node = $this
->drupalGetNodeByTitle($title);
$this
->assertTrue($node, "Node was created");
return $node;
}