Problem/Motivation

Running the tests in any issue fork leads to a test error, while the (old) test status on the project page is still green.

Created 9 May 2023 at 16:25 CEST. 679eab97922f51b95e975a1accaf2b99f3c2729c pushed to 3356155-update-twig-twig-minimum merge request. Updated 9 May 2023 at 16:27 CEST.

10 pass, 1 fail - View results on dispatcher
Show: Failing classes All
		
✓	✗	
10	1	Twig_tweak.Twig_tweak
	1	Twig_tweak.Drupal\Tests\twig_tweak\Kernel\EntityViewBuilderTest
	✗	
Drupal\Tests\twig_tweak\Kernel\EntityViewBuilderTest

fail: [Other] Line 0 of sites/default/files/simpletest/phpunit-7.xml:
PHPUnit Test failed to complete; Error: PHPUnit 9.6.7 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\twig_tweak\Kernel\EntityViewBuilderTest
F                                                                   1 / 1 (100%)

Time: 00:00.883, Memory: 4.00 MB

There was 1 failure:

1) Drupal\Tests\twig_tweak\Kernel\EntityViewBuilderTest::testEntityViewBuilder
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'Public node'
+'Public node'

/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:122
/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/IsIdentical.php:79
/var/www/html/modules/contrib/twig_tweak/tests/src/Kernel/EntityViewBuilderTest.php:95
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728

FAILURES!
Tests: 1, Assertions: 16, Failures: 1.

Locally all tests pass, so it might be an issue with Drupal CI or Issue forks?

Steps to reproduce

Create an issue (like this) with no relevant changes and see the test fail

Proposed resolution

Rerun tests at https://www.drupal.org/node/2643614/qa to check if this also fails
Fix the test (unclear what's wrong)

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork twig_tweak-3359306

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Anybody created an issue. See original summary.

anybody’s picture

Issue summary: View changes

anybody’s picture

Title: Fix failing test » 3359306-fix-failing-test-example

Queueing a test to show the issue without changing anything!

anybody’s picture

Title: 3359306-fix-failing-test-example » Fix failing test
anybody’s picture

Okay let's hope linebreaks or hidden characters are the reason... the last tests at least shows some differences to start with:

--- Expected
+++ Actual
@@ @@
-'  
-    Public node
-    
-  '
+'
+
+
+      
+      
+Public node
+
+    
+
+
+
+
+  
+
+  
+
+
+'
anybody’s picture

Title: Fix failing test » Fix failing test since Drupal 10.1.x
Status: Active » Needs work
Related issues: +#3153468: Strip HTML tags when using assertEquals() to compare markup

Interesting, looks like this test fails since 10.1.x
Might this be related to #3153468: Strip HTML tags when using assertEquals() to compare markup perhaps?

Still couldn't find a difference between:

-'Public node'
+'Public node'

and guess it must be something like a hidden character, escaping or something like that... -.-

anybody’s picture

Okay I was now able to reproduce this locally, after upgrading to 10.1.x-dev!

Here are the correct details, invisible online:

1) Drupal\Tests\twig_tweak\Kernel\EntityViewBuilderTest::testEntityViewBuilder
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'<article role="article"><h2><a href="/node/1" rel="bookmark"><span>Public node</span></a></h2><div></div></article>'
+'<article><h2><a href="/node/1" rel="bookmark"><span>Public node</span></a></h2><div></div></article>'

/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:122
/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/IsIdentical.php:79
/var/www/html/web/modules/contrib/twig_tweak/tests/src/Kernel/EntityViewBuilderTest.php:95
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
anybody’s picture

Status: Needs work » Active

I tried switching to self::assertXmlStringEqualsXmlString() so it doesn't need all the ugly markup cleanups anymore, but sadly there seems to be a bug in PHPUnit 9,x (9.5 required by Drupal 10.1.x) so it's not usable (yet):

Fatal error: Uncaught Exception: Serialization of 'DOMDocument' is not allowed in Standard input code:84

Similar here:
https://github.com/RSS-Bridge/rss-bridge/issues/2704

I couldn't find a way around it, so I'll proceed with the (ugly) cleanups for now. But as soon as possible, that should better be switched, I guess.

anybody’s picture

anybody’s picture

@Chi: Would be super cool if you could merge this, as the failing tests currently polute the other issues test results.
See #10 for the root cause (core template change).

Only for that reason I'm setting the priority to major.

anybody’s picture

Priority: Normal » Major
chi’s picture

Status: Needs review » Closed (outdated)

Sorry totally missed this issue.
Moving credits to #3363045: Cheat sheet: format_size fliter needs explanation.