Problem/Motivation

Follow-up to #2321721-71: Provide a views relationship for each dynamic entity reference field
@dawehner said

Did you ever tried to place a DER field as part of basefields?

We don't have a proper test for this.

Proposed resolution

Add entity_test_der as new test entity and check it's view integration and field CRUD operation.

Remaining tasks

Write a patch

User interface changes

None

API changes

None

Data model changes

None

Comments

jibran’s picture

StatusFileSize
new13.86 KB

Added EntityUnit tests
Needs functional tests.

larowlan’s picture

  1. +++ b/src/Tests/DynamicEntityReferenceBaseFieldTest.php
    @@ -57,34 +54,44 @@ class DynamicEntityReferenceFieldTest extends EntityUnitTestBase {
    +  public static $testRunCount = 0;
    ...
    +    static::$testRunCount++;
    ...
    +    if (static::$testRunCount == 2) {
    

    Can't each test have a property $numberOfFieldsToCreate this looks fragile

  2. +++ b/tests/modules/dynamic_entity_reference_entity_test/dynamic_entity_reference_entity_test.module
    @@ -0,0 +1,75 @@
    +    if (\Drupal::config('dynamic_entity_reference_entity_test.settings')->get('exclude') == 'entity_test') {
    ...
    +    if (\Drupal::config('dynamic_entity_reference_entity_test.settings')->get('multiple')) {
    

    Any reason not to use state here instead? Most tests use state for this kind of thing

    Saves you the schema and default too

jibran’s picture

StatusFileSize
new6.45 KB
new12.41 KB

Nice catches fixed both of the issues.

jibran’s picture

StatusFileSize
new22.95 KB
new21.22 KB

It is ready for review added functional tests.

Status: Needs review » Needs work

The last submitted patch, 4: write_tests_for_der-2542274-4.patch, failed testing.

The last submitted patch, 4: write_tests_for_der-2542274-4.patch, failed testing.

jibran’s picture

Status: Needs work » Needs review
StatusFileSize
new1011 bytes
new20.76 KB

Chasing HEAD.

jibran’s picture

StatusFileSize
new6.67 KB
new26.67 KB

Added single value field test.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/src/Tests/DynamicEntityReferenceBaseTest.php
@@ -0,0 +1,365 @@
+    \Drupal::state()->set('dynamic_entity_reference_cardinality', -1);

Should we use the constant here (nit - fix on commit)

Wow - this is awesome!

jibran’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the review. Attached the interdiff fixed on commit.

jibran’s picture

StatusFileSize
new4.46 KB

  • jibran committed 9dddffc on
    Issue #2542274 by jibran, larowlan: Write tests for DER field as...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.