Problem/Motivation

We have way two many bugs in DER formatters see #2403625: isApplicable() on formatter is not overridden, causing an exception and #2389605: DER's "autocreate" feature is mostly broken (and untested). We need tests.

Proposed resolution

Add tests

Remaining tasks

Create a patch with tests.
Review.
Commit.

User interface changes

None.

API changes

None.

CommentFileSizeAuthor
#1 add_tests_for_all_the-2405013-1.patch13.32 KBjibran

Comments

jibran’s picture

Status: Active » Needs review
Issue tags: -Need tests
StatusFileSize
new13.32 KB
larowlan’s picture

Love that this is a unit-test, so will be quick. Brilliant work!
Just one question:

+++ b/src/Tests/DynamicEntityReferenceFormatterTest.php
@@ -0,0 +1,319 @@
+    $expected_rendered_name_field_1 = '<div class="field field-entity-test--name field-name-name field-type-string field-label-hidden">
+    <div class="field-items">
+          <div class="field-item">' . $this->referencedEntity->label() . '</div>
+      </div>
+</div>
+';
+    $expected_rendered_body_field_1 = '<div class="clearfix field field-entity-test--body field-name-body field-type-text field-label-above">
+      <div class="field-label">Body</div>
+    <div class="field-items">
+          <div class="field-item"><p>Hello, world!</p></div>
+      </div>
+</div>

Does this make the test fragile if further css changes in core remove some of these divs?

jibran’s picture

I practically copied EntityReferenceFormatterTest but let me see perhaps we can use some kind of theme function here. IMO this is html so fragile is better.

jibran’s picture

No We can't use theme function here. The only way to test it is to test the raw markup and we have no other way then this.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

ok

jibran’s picture

Status: Reviewed & tested by the community » Fixed

Thanks.

  • jibran committed a6c692b on 8.x-1.x
    Issue #2405013 by jibran, larowlan: Add tests for all the formatters
    

Status: Fixed » Closed (fixed)

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