You are here

protected function QuickEditJavascriptTestBase::assertEntityInstanceStates in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditJavascriptTestBase.php \Drupal\Tests\quickedit\FunctionalJavascript\QuickEditJavascriptTestBase::assertEntityInstanceStates()
  2. 10 core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditJavascriptTestBase.php \Drupal\Tests\quickedit\FunctionalJavascript\QuickEditJavascriptTestBase::assertEntityInstanceStates()

Asserts all EntityModels (entity instances) on the page.

Parameters

array $expected_entity_states: Must describe the expected state of all in-place editable entity instances on the page.

See also

Drupal.quickedit.EntityModel

4 calls to QuickEditJavascriptTestBase::assertEntityInstanceStates()
LayoutBuilderQuickEditTest::assertQuickEditInit in core/modules/quickedit/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php
Asserts that Quick Edit is initialized on the node view correctly.
QuickEditImageTest::testImageInPlaceEditor in core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditImageTest.php
Tests that quick editor works correctly with images.
QuickEditIntegrationTest::testArticleNode in core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php
Tests if an article node can be in-place edited with Quick Edit.
QuickEditIntegrationTest::testCustomBlock in core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php
Tests if a custom can be in-place edited with Quick Edit.

File

core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditJavascriptTestBase.php, line 195

Class

QuickEditJavascriptTestBase
Base class for testing the QuickEdit.

Namespace

Drupal\Tests\quickedit\FunctionalJavascript

Code

protected function assertEntityInstanceStates(array $expected_entity_states) {
  $js_get_all_field_states_for_entity = <<<JS
function () {
    Drupal.quickedit.collections.entities.reduce(function (result, fieldModel) { result[fieldModel.get('id')] = fieldModel.get('state'); return result; }, {})
  var entityCollection = Drupal.quickedit.collections.entities;
  return entityCollection.reduce(function (result, entityModel) {
    result[entityModel.id] = entityModel.get('state');
    return result;
  }, {});
}()
JS;
  $this
    ->assertSame($expected_entity_states, $this
    ->getSession()
    ->evaluateScript($js_get_all_field_states_for_entity));
}