protected function ContentEntityAutosaveFormTestBase::makeAllEntityFormChanges in Autosave Form 8
Executes all change steps.
Parameters
mixed $entity_id: The ID of the entity.
Return value
array An array keyed by the change ID and having as value the latest autosave timestamp.
2 calls to ContentEntityAutosaveFormTestBase::makeAllEntityFormChanges()
- ContentEntityAutosaveFormTestBase::doTestAutosaveFormExistingEntity in tests/
src/ FunctionalJavascript/ ContentEntity/ ContentEntityAutosaveFormTestBase.php - Tests the autosave support on entity forms.
- ContentEntityAutosaveFormTestBase::doTestSavingRestoredEntityForm in tests/
src/ FunctionalJavascript/ ContentEntity/ ContentEntityAutosaveFormTestBase.php - Tests saving an entity form restored from an autosaved state.
File
- tests/
src/ FunctionalJavascript/ ContentEntity/ ContentEntityAutosaveFormTestBase.php, line 362
Class
- ContentEntityAutosaveFormTestBase
- Base test class for testing autosave support for entity forms.
Namespace
Drupal\Tests\autosave_form\FunctionalJavascript\ContentEntityCode
protected function makeAllEntityFormChanges($entity_id) {
$this
->logHtmlOutput(__FUNCTION__ . ' before changes are made');
// Assure the first autosave submission for gathering the initial input has
// been executed before making any changes, otherwise it might happen that
// a change is made too fast and makes its way into the initial user input
// used for comparison in order to determine if a new autosave state has
// to be created or not.
$this
->assertTrue($this
->waitForAutosaveSubmits(1));
$latest_autosave_timestamp_per_change = [];
for ($change_id = 1; $change_id <= $this->testAutosaveFormExistingEntityChangesCount; $change_id++) {
$before_change_autosave_entries = $this
->getCountAutosaveEntries($entity_id);
$this
->makeEntityFormChange($change_id);
// Assert that a new autosave has been created, but wait for at least two
// autosave submits to exclude any race conditions.
$this
->assertTrue($this
->waitForAutosaveSubmits(2));
$after_change_autosave_entries = $this
->getCountAutosaveEntries($entity_id);
$this
->assertTrue($after_change_autosave_entries > $before_change_autosave_entries);
// Wait for at least two more autosave submits to ensure no additional
// autosave states are being created.
$this
->assertTrue($this
->waitForAutosaveSubmits(2));
$this
->assertEquals($after_change_autosave_entries, $this
->getCountAutosaveEntries($entity_id));
$latest_autosave_timestamp_per_change[$change_id] = $this
->getLastAutosaveTimestamp($entity_id);
}
$this
->logHtmlOutput(__FUNCTION__ . ' after changes are made');
return $latest_autosave_timestamp_per_change;
}