Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • project/dynamic_entity_reference
  • issue/dynamic_entity_reference-3204541
  • issue/dynamic_entity_reference-3222612
  • issue/dynamic_entity_reference-3225095
  • issue/dynamic_entity_reference-3236305
  • issue/dynamic_entity_reference-3259682
  • issue/dynamic_entity_reference-3262121
  • issue/dynamic_entity_reference-3327354
  • issue/dynamic_entity_reference-3331727
  • issue/dynamic_entity_reference-3344614
  • issue/dynamic_entity_reference-3350347
  • issue/dynamic_entity_reference-3354499
  • issue/dynamic_entity_reference-3400702
  • issue/dynamic_entity_reference-3405253
  • issue/dynamic_entity_reference-3377096
  • issue/dynamic_entity_reference-3380619
  • issue/dynamic_entity_reference-3384721
  • issue/dynamic_entity_reference-3414702
  • issue/dynamic_entity_reference-3414923
  • issue/dynamic_entity_reference-3441089
  • issue/dynamic_entity_reference-3439808
  • issue/dynamic_entity_reference-3438307
  • issue/dynamic_entity_reference-2766213
  • issue/dynamic_entity_reference-3488982
  • issue/dynamic_entity_reference-3499558
  • issue/dynamic_entity_reference-3499559
26 results
Show changes
Commits on Source (5)
version: 2.1
workflows:
test:
jobs:
- test:
matrix:
parameters:
php: ["8.1", "8.2"]
drupal-version: ["10.1.x", "11.x"]
# Run nightly tests every day 8 AM.
nightly:
jobs:
- test:
matrix:
parameters:
php: ["8.1", "8.2"]
drupal-version: ["10.1.x", "11.x"]
triggers:
- schedule:
# Weekday (22=10pm UTC). Evaluates to 8am AEST.
cron: "0 22 * * *"
filters:
branches:
only:
- 3.x
- 4.x
jobs:
test:
parameters:
php:
type: string
drupal-version:
type: string
docker:
- image: skpr/php-circleci:<< parameters.php >>-v2-latest
environment:
MODULE_NAME: dynamic_entity_reference
SIMPLETEST_BASE_URL: http://127.0.0.1:8080
SIMPLETEST_DB: mysql://drupal:drupal@127.0.0.1/local
BROWSERTEST_OUTPUT_FILE: /data/app/sites/simpletest/browser_output.html
BROWSERTEST_OUTPUT_DIRECTORY: /data/app/sites/simpletest/browser_output
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"chromeOptions": { "args": [ "--disable-gpu", "--headless" ] } }, "http://127.0.0.1:4444/wd/hub" ]'
- image: mariadb
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: local
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
- image: selenium/standalone-chrome:3.141.59-oxygen
working_directory: /data/app
steps:
- setup_remote_docker:
docker_layer_caching: true
- add_ssh_keys:
fingerprints:
- a6:e4:76:63:c3:bf:5e:a5:cf:0e:0b:a1:7e:c9:c0:21
- run:
name: Download specified drupal version
command: |
git clone --depth 1 --branch << parameters.drupal-version >> \
https://git.drupal.org/project/drupal.git .
git log -1 --oneline
- run:
name: Fetch drupal dependencies, dev dependencies, and module test dependencies
command: |
composer install --prefer-dist --no-progress
composer require --dev "phpstan/phpstan-deprecation-rules:^1.0"
- run:
name: Show all installed composer packages.
command: composer show
- checkout:
path: modules/${MODULE_NAME}
- run:
name: Setup Directories
command: |
mkdir -p sites/default/files/tmp \
sites/default/private \
sites/simpletest/browser_output \
../build/logs/phpunit \
../build/logs/phpstan \
../build/logs/phpcs
cp modules/${MODULE_NAME}/phpstan.neon .
chmod -R 2775 sites/default/files sites/default/private sites/simpletest ../build/logs
chown -R skpr:skpr /data
- run:
name: Lint PHP against Drupal coding standards
command: |
vendor/bin/phpcs \
--standard=vendor/drupal/coder/coder_sniffer/Drupal \
--extensions=php,module,inc,install,test,profile,theme,css,info \
--ignore=*.md \
--report=junit \
--report-file=../build/logs/phpcs/phpcs.xml \
modules/${MODULE_NAME}
- run:
name: PHPStan
command: |
vendor/bin/phpstan analyze \
--memory-limit=-1 \
--no-progress \
--error-format=junit \
-- modules/${MODULE_NAME} \
> ../build/logs/phpstan/phpstan.xml
- run:
name: "Start: PHP-FPM"
command: php-fpm -F
background: true
- run:
name: "Start: Nginx"
command: nginx
background: true
- run:
name: Run unit tests
command: |
./vendor/bin/phpunit --configuration ./core/phpunit.xml.dist --log-junit ../build/logs/phpunit/phpunit.xml modules/${MODULE_NAME}
# ./vendor/bin/phpunit --verbose --configuration ./core/phpunit.xml.dist --log-junit ../build/logs/phpunit/phpunit.xml modules/${MODULE_NAME}
# ./vendor/bin/phpunit --debug --verbose --configuration ./core/phpunit.xml.dist --log-junit ../build/logs/phpunit/phpunit.xml modules/${MODULE_NAME}
- store_test_results:
path: /data/build/logs
- store_artifacts:
path: /data/app/sites/simpletest/browser_output
# This is the DrupalCI testbot build file for Dynamic Entity Reference.
# Learn to make one for your own drupal.org project:
# https://www.drupal.org/drupalorg/docs/drupal-ci/customizing-drupalci-testing
build:
assessment:
validate_codebase:
# eslint-disable-next-line yml/no-empty-mapping-value
phplint:
phpcs:
# phpcs will use core's specified version of Coder.
sniff-all-files: true
halt-on-fail: true
testing:
# run_tests task is executed several times in order of performance speeds.
# halt-on-fail can be set on the run_tests tasks in order to fail fast.
# suppress-deprecations is false in order to be alerted to usages of
# deprecated code.
run_tests.phpunit:
types: "PHPUnit-Unit"
testgroups: "--all"
suppress-deprecations: false
halt-on-fail: false
run_tests.kernel:
types: "PHPUnit-Kernel"
testgroups: "--all"
suppress-deprecations: false
halt-on-fail: false
run_tests.functional:
types: "PHPUnit-Functional"
testgroups: "--all"
suppress-deprecations: false
halt-on-fail: false
run_tests.javascript:
concurrency: 15
types: "PHPUnit-FunctionalJavascript"
testgroups: "--all"
suppress-deprecations: false
halt-on-fail: false
logo.png

1.59 KiB

......@@ -150,7 +150,7 @@ class DynamicEntityReferenceItem extends EntityReferenceItem {
*
* @see \Drupal\dynamic_entity_reference\Plugin\Field\FieldWidget\DynamicEntityReferenceOptionsTrait::massageFormValues()
*/
public function getSettableOptions(AccountInterface $account = NULL) {
public function getSettableOptions(?AccountInterface $account = NULL) {
$field_definition = $this->getFieldDefinition();
$entity_type_manager = \Drupal::entityTypeManager();
$entity_type_bundles_info = \Drupal::service('entity_type.bundle.info');
......
......@@ -17,7 +17,7 @@ class SelectionPluginManager extends CoreSelectionPluginManager {
/**
* {@inheritdoc}
*/
public function getSelectionHandler(FieldDefinitionInterface $field_definition, EntityInterface $entity = NULL, $target_type = NULL) {
public function getSelectionHandler(FieldDefinitionInterface $field_definition, ?EntityInterface $entity = NULL, $target_type = NULL) {
if ($target_type === NULL) {
return parent::getSelectionHandler($field_definition, $entity);
}
......
......@@ -104,7 +104,7 @@ class DynamicEntityReferenceBaseTest extends BrowserTestBase {
'user_id[0][target_id]' => $this->adminUser->label() . ' (' . $this->adminUser->id() . ')',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$entities = \Drupal::entityTypeManager()
->getStorage('entity_test')
->loadByProperties([
......@@ -126,7 +126,7 @@ class DynamicEntityReferenceBaseTest extends BrowserTestBase {
// Remove one child.
'dynamic_references[0][target_id]' => '',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$this->drupalGet('entity_test/' . $entity->id());
$assert_session->pageTextContains('Bazbar');
// Reload entity.
......@@ -152,11 +152,11 @@ class DynamicEntityReferenceBaseTest extends BrowserTestBase {
$edit = [
'dynamic_references[0][target_id]' => 'duplicate label',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
// We don't know the order in which the entities will be listed, so just
// assert parts and make sure both are shown.
$error_message = t('Multiple test entity entities match this reference;');
$error_message = 'Multiple test entity entities match this reference;';
$assert_session->responseContains($error_message);
$assert_session->responseContains($labels[0]);
$assert_session->responseContains($labels[1]);
......@@ -172,15 +172,11 @@ class DynamicEntityReferenceBaseTest extends BrowserTestBase {
}
// Submit again with the same values.
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$params = [
'%value' => 'duplicate label',
];
// We don't know which id it will display, so just assert a part of the
// error.
$error_message = t('Many test entity entities are called %value. Specify the one you want by appending the id in parentheses', $params);
$assert_session->responseContains($error_message);
$assert_session->pageTextContains('Many test entity entities are called duplicate label. Specify the one you want by appending the id in parentheses');
// Submit with a label that does not match anything.
// Now try to submit and just specify the label.
......@@ -188,8 +184,8 @@ class DynamicEntityReferenceBaseTest extends BrowserTestBase {
$edit = [
'dynamic_references[0][target_id]' => 'does not exist',
];
$this->submitForm($edit, t('Save'));
$assert_session->responseContains(t('There are no test entity entities matching "%value".', ['%value' => 'does not exist']));
$this->submitForm($edit, 'Save');
$assert_session->pageTextContains('There are no test entity entities matching "does not exist".');
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
$edit = [
......@@ -197,7 +193,7 @@ class DynamicEntityReferenceBaseTest extends BrowserTestBase {
// Reference itself.
'dynamic_references[0][target_id]' => 'Bazbar (' . $entity->id() . ')',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$this->drupalGet('entity_test/' . $entity->id());
$assert_session->pageTextContains('Bazbar');
// Reload entity.
......@@ -262,7 +258,7 @@ class DynamicEntityReferenceBaseTest extends BrowserTestBase {
'user_id[0][target_id]' => $this->adminUser->label() . ' (' . $this->adminUser->id() . ')',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$entities = \Drupal::entityTypeManager()
->getStorage('entity_test')
->loadByProperties(['name' => 'Barfoo']);
......@@ -284,7 +280,7 @@ class DynamicEntityReferenceBaseTest extends BrowserTestBase {
// Remove one child.
'dynamic_references[1][target_id]' => '',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$this->drupalGet('entity_test/' . $entity->id());
$assert_session->pageTextContains('Bazbar');
// Reload entity.
......@@ -310,12 +306,11 @@ class DynamicEntityReferenceBaseTest extends BrowserTestBase {
$edit = [
'dynamic_references[1][target_id]' => 'duplicate label',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
// We don't know the order in which the entities will be listed, so just
// assert parts and make sure both are shown.
$error_message = t('Multiple test entity entities match this reference;');
$assert_session->responseContains($error_message);
$assert_session->responseContains('Multiple test entity entities match this reference;');
$assert_session->responseContains($labels[0]);
$assert_session->responseContains($labels[1]);
......@@ -330,15 +325,11 @@ class DynamicEntityReferenceBaseTest extends BrowserTestBase {
}
// Submit again with the same values.
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$params = [
'%value' => 'duplicate label',
];
// We don't know which id it will display, so just assert a part of the
// error.
$error_message = t('Many test entity entities are called %value. Specify the one you want by appending the id in parentheses', $params);
$assert_session->responseContains($error_message);
$assert_session->pageTextContains('Many test entity entities are called duplicate label. Specify the one you want by appending the id in parentheses');
// Submit with a label that does not match anything.
// Now try to submit and just specify the label.
......@@ -346,8 +337,8 @@ class DynamicEntityReferenceBaseTest extends BrowserTestBase {
$edit = [
'dynamic_references[1][target_id]' => 'does not exist',
];
$this->submitForm($edit, t('Save'));
$assert_session->responseContains(t('There are no test entity entities matching "%value".', ['%value' => 'does not exist']));
$this->submitForm($edit, 'Save');
$assert_session->pageTextContains('There are no test entity entities matching "does not exist".');
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
$edit = [
......@@ -355,7 +346,7 @@ class DynamicEntityReferenceBaseTest extends BrowserTestBase {
// Reference itself.
'dynamic_references[1][target_id]' => 'Bazbar (' . $entity->id() . ')',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$this->drupalGet('entity_test/' . $entity->id());
$assert_session->pageTextContains('Bazbar');
// Reload entity.
......
......@@ -118,7 +118,7 @@ class DynamicEntityReferenceFieldDefaultValueTest extends BrowserTestBase {
'default_value_input[' . $field_name . '][0][target_id]' => $referenced_node->getTitle() . ' (' . $referenced_node->id() . ')',
];
$this->drupalGet('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $field_name);
$this->submitForm($field_edit, t('Save settings'));
$this->submitForm($field_edit, 'Save settings');
$field_config = \Drupal::entityTypeManager()->getStorage('field_config')->loadUnchanged($field_config->id());
$default_value = $field_config->getDefaultValueLiteral();
$this->assertNotEmpty($default_value);
......
......@@ -77,6 +77,7 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'entity_test_map_field',
'entity_test_no_bundle_with_label',
'entity_test_unique_constraint',
'entity_test_uuid_id',
];
/**
......@@ -146,9 +147,9 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'group_field_options_wrapper' => 'dynamic_entity_reference',
'label' => 'Foobar',
'field_name' => 'foobar',
], t('Continue'));
], 'Continue');
$field_name = 'field_storage[subform][settings][entity_type_ids][]';
$button_label = t('Save settings');
$button_label = 'Save settings';
$cardinality_field = 'field_storage[subform][cardinality]';
$additions += $edit;
$edit_path = 'entity_test/structure/entity_test/fields/entity_test.entity_test.field_foobar';
......@@ -160,9 +161,9 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'label' => 'Foobar',
'field_name' => 'foobar',
'new_storage_type' => 'dynamic_entity_reference',
], t('Save and continue'));
], 'Save and continue');
$field_name = 'settings[entity_type_ids][]';
$button_label = t('Save field settings');
$button_label = 'Save field settings';
$cardinality_field = 'cardinality';
$exclude_field_name = 'settings[exclude_entity_types]';
}
......@@ -170,13 +171,13 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
$assert_session->optionNotExists($field_name, 'settings[entity_test_no_id][handler_settings][target_bundles][entity_test_string_id]');
$assert_session->fieldExists($cardinality_field)->setValue(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$assert_session->fieldExists($field_name)->setValue(['user', 'entity_test_label']);
$assert_session->buttonExists(t('Update settings'))->click();
$assert_session->buttonExists('Update settings')->click();
$assert_session->fieldExists('default_value_input[field_foobar][0][target_type]');
$assert_session->optionExists('default_value_input[field_foobar][0][target_type]', 'entity_test');
$assert_session->optionNotExists('default_value_input[field_foobar][0][target_type]', 'user');
$this->submitForm($additions, $button_label);
$assert_session->responseContains(t('Saved %name configuration', ['%name' => 'Foobar']));
$assert_session->pageTextContains('Saved Foobar configuration');
$excluded_entity_type_ids = FieldStorageConfig::loadByName('entity_test', 'field_foobar')
->getSetting('entity_type_ids');
$this->assertNotNull($excluded_entity_type_ids);
......@@ -215,8 +216,8 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
$edit = [
'settings[entity_test_label][handler_settings][target_bundles][entity_test_label]' => 'entity_test_label',
];
$this->submitForm($edit, t('Save settings'));
$assert_session->responseContains(t('Saved %name configuration', ['%name' => 'Foobar']));
$this->submitForm($edit, 'Save settings');
$assert_session->pageTextContains('Saved Foobar configuration');
$excluded_entity_type_ids = FieldStorageConfig::loadByName('entity_test', 'field_foobar')
->getSetting('entity_type_ids');
$this->assertNotNull($excluded_entity_type_ids);
......@@ -232,7 +233,7 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'set_default_value' => '1',
'default_value_input[field_foobar][0][target_type]' => 'user',
'default_value_input[field_foobar][0][target_id]' => $this->adminUser->label() . ' (' . $this->adminUser->id() . ')',
], t('Save settings'));
], 'Save settings');
$field_config = FieldConfig::loadByName('entity_test', 'entity_test', 'field_foobar')->toArray();
$this->assertEquals($field_config['default_value']['0'], [
......@@ -257,9 +258,9 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'group_field_options_wrapper' => 'dynamic_entity_reference',
'label' => 'Foobar',
'field_name' => 'foobar',
], t('Continue'));
], 'Continue');
$field_name = 'field_storage[subform][settings][entity_type_ids][]';
$button_label = t('Save settings');
$button_label = 'Save settings';
$cardinality_field = 'field_storage[subform][cardinality]';
}
else {
......@@ -267,9 +268,9 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'label' => 'Foobar',
'field_name' => 'foobar',
'new_storage_type' => 'dynamic_entity_reference',
], t('Save and continue'));
], 'Save and continue');
$field_name = 'settings[entity_type_ids][]';
$button_label = t('Save field settings');
$button_label = 'Save field settings';
$cardinality_field = 'cardinality';
}
$assert_session->optionNotExists($field_name, 'settings[entity_test_no_id][handler_settings][target_bundles][entity_test_no_id]');
......@@ -294,8 +295,8 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
}
}
}
$this->submitForm($edit, t('Save settings'));
$assert_session->responseContains(t('Saved %name configuration', ['%name' => 'Foobar']));
$this->submitForm($edit, 'Save settings');
$assert_session->pageTextContains('Saved Foobar configuration');
\Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
// Create some items to reference.
......@@ -347,7 +348,7 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'user_id[0][target_id]' => $this->adminUser->label() . ' (' . $this->adminUser->id() . ')',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$entities = \Drupal::entityTypeManager()
->getStorage('entity_test')
->loadByProperties(['name' => 'Barfoo']);
......@@ -394,7 +395,7 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
// Remove one child.
'field_foobar[2][target_id]' => '',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$this->drupalGet('entity_test/' . $entity->id());
$assert_session->pageTextContains('Bazbar');
// Reload entity.
......@@ -420,12 +421,11 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
$edit = [
'field_foobar[1][target_id]' => 'duplicate label',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
// We don't know the order in which the entities will be listed, so just
// assert parts and make sure both are shown.
$error_message = t('Multiple test entity entities match this reference;');
$assert_session->responseContains($error_message);
$assert_session->responseContains('Multiple test entity entities match this reference;');
$assert_session->responseContains($labels[0]);
$assert_session->responseContains($labels[1]);
......@@ -440,15 +440,11 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
}
// Submit again with the same values.
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$params = [
'%value' => 'duplicate label',
];
// We don't know which id it will display, so just assert a part of the
// error.
$error_message = t('Many test entity entities are called %value. Specify the one you want by appending the id in parentheses', $params);
$assert_session->responseContains($error_message);
$assert_session->pageTextContains('Many test entity entities are called duplicate label. Specify the one you want by appending the id in parentheses');
// Submit with a label that does not match anything.
// Now try to submit and just specify the label.
......@@ -456,9 +452,9 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
$edit = [
'field_foobar[1][target_id]' => 'does not exist',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$assert_session->responseContains(t('There are no test entity entities matching "%value".', ['%value' => 'does not exist']));
$assert_session->pageTextContains('There are no test entity entities matching "does not exist".');
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
$edit = [
......@@ -466,7 +462,7 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
// Reference itself.
'field_foobar[1][target_id]' => 'Bazbar (' . $entity->id() . ')',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$this->drupalGet('entity_test/' . $entity->id());
$assert_session->pageTextContains('Bazbar');
// Reload entity.
......@@ -512,9 +508,9 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'group_field_options_wrapper' => 'dynamic_entity_reference',
'label' => 'Foobar',
'field_name' => 'foobar',
], t('Continue'));
], 'Continue');
$field_name = 'field_storage[subform][settings][entity_type_ids][]';
$button_label = t('Save settings');
$button_label = 'Save settings';
$cardinality_field = 'field_storage[subform][cardinality]';
$exclude_field_name = 'field_storage[subform][settings][exclude_entity_types]';
}
......@@ -523,9 +519,9 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'label' => 'Foobar',
'field_name' => 'foobar',
'new_storage_type' => 'dynamic_entity_reference',
], t('Save and continue'));
], 'Save and continue');
$field_name = 'settings[entity_type_ids][]';
$button_label = t('Save field settings');
$button_label = 'Save field settings';
$cardinality_field = 'cardinality';
$exclude_field_name = 'settings[exclude_entity_types]';
}
......@@ -555,7 +551,7 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'user_id[0][target_id]' => $this->adminUser->label() . ' (' . $this->adminUser->id() . ')',
];
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$entities = \Drupal::entityTypeManager()
->getStorage('entity_test')
......@@ -622,9 +618,9 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'group_field_options_wrapper' => 'dynamic_entity_reference',
'label' => 'Foobar',
'field_name' => 'der',
], t('Continue'));
], 'Continue');
$field_name = 'field_storage[subform][settings][entity_type_ids][]';
$button_label = t('Save settings');
$button_label = 'Save settings';
$cardinality_field = 'field_storage[subform][cardinality]';
$exclude_field_name = 'field_storage[subform][settings][exclude_entity_types]';
$additional = $edit;
......@@ -634,9 +630,9 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'label' => 'Foobar',
'field_name' => 'der',
'new_storage_type' => 'dynamic_entity_reference',
], t('Save and continue'));
], 'Save and continue');
$field_name = 'settings[entity_type_ids][]';
$button_label = t('Save field settings');
$button_label = 'Save field settings';
$cardinality_field = 'cardinality';
$exclude_field_name = 'settings[exclude_entity_types]';
}
......@@ -662,7 +658,7 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'uid[0][target_id]' => $this->adminUser->label() . ' (' . $this->adminUser->id() . ')',
];
$this->submitForm($edit, t('Preview'));
$this->submitForm($edit, 'Preview');
$assert_session->pageTextContains($title);
$assert_session->pageTextContains($term->label());
// Back to node add page.
......@@ -682,13 +678,12 @@ class DynamicEntityReferenceTest extends BrowserTestBase {
'uid[0][target_id]' => $this->adminUser->label() . ' (' . $this->adminUser->id() . ')',
];
$this->submitForm($edit, t('Preview'));
$this->submitForm($edit, 'Preview');
$assert_session->pageTextContains($title);
$assert_session->pageTextContains($new_term);
// Back to node add page.
$this->clickLink('Back to content editing');
$assert_session->fieldValueEquals('field_der[0][target_id]', $new_term);
}
}
......@@ -123,12 +123,9 @@ class DynamicEntityReferenceWidgetTest extends BrowserTestBase {
// Only 1 target_type is configured, so this field is not available on the
// node add/edit page.
$assert_session->fieldNotExists($field_name . '[0][target_type]');
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$node = $this->drupalGetNodeByTitle($title);
$assert_session->responseContains(t('@type %title has been created.', [
'@type' => 'reference_content',
'%title' => $node->toLink($node->label())->toString(),
]));
$assert_session->pageTextContains(sprintf('reference_content %s has been created.', $node->label()));
$nodes = \Drupal::entityTypeManager()
->getStorage('node')
->loadByProperties(['title' => $title]);
......@@ -157,12 +154,10 @@ class DynamicEntityReferenceWidgetTest extends BrowserTestBase {
$field_name => $referenced_node->getEntityTypeId() . '-' . $referenced_node->id(),
];
$this->drupalGet(Url::fromRoute('node.add', ['node_type' => 'reference_content']));
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$node = $this->drupalGetNodeByTitle($title);
$assert_session->responseContains(t('@type %title has been created.', [
'@type' => 'reference_content',
'%title' => $node->toLink($node->label())->toString(),
]));
$assert_session->pageTextContains(sprintf('reference_content %s has been created.', $node->label()));
$nodes = \Drupal::entityTypeManager()
->getStorage('node')
->loadByProperties(['title' => $title]);
......@@ -195,12 +190,10 @@ class DynamicEntityReferenceWidgetTest extends BrowserTestBase {
// Only one bundle is configuerd, so optgroup should not be added to
// the select element.
$assert_session->elementNotContains('css', '[name=' . $field_name . ']', 'optgroup');
$this->submitForm($edit, t('Save'));
$this->submitForm($edit, 'Save');
$node = $this->drupalGetNodeByTitle($title);
$assert_session->responseContains(t('@type %title has been created.', [
'@type' => 'reference_content',
'%title' => $node->toLink($node->label())->toString(),
]));
$assert_session->pageTextContains(sprintf('reference_content %s has been created.', $node->label()));
$nodes = \Drupal::entityTypeManager()
->getStorage('node')
->loadByProperties(['title' => $title]);
......@@ -225,7 +218,6 @@ class DynamicEntityReferenceWidgetTest extends BrowserTestBase {
$assert_session->elementContains('css', '[name=' . $field_name . ']', 'optgroup');
$field_config->setSetting('node', $node_setting);
}
}
......@@ -215,9 +215,8 @@ class DynamicEntityReferenceTest extends WebDriverTestBase {
// path for delta 1 autocomplete field.
$this->assertSame($autocomplete_field_1->getAttribute('data-autocomplete-path'), $entity_test_path);
$page = $this->getSession()->getPage();
$assert_session->assertWaitOnAjaxRequest(20000);
$page->checkField('settings[entity_test][handler_settings][auto_create]');
$this->submitForm([], t('Save settings'));
$this->submitForm([], 'Save settings');
$assert_session->pageTextContains('Saved Foobar configuration');
\Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
$this->drupalGet('entity_test/add');
......