\Drupal\Tests\metatag\Functional\MetatagTagsTestBase::$tags property is defined as private. This means that child classes do not override it, they define their own $tags properties instead. Since test methods are also defined in the base class, it loops through its own $tags property i.e. empty array, not a child class $tags property. The property should be defined as protected or public instead.

Looks like the issue was introduced in this commit https://git.drupalcode.org/project/metatag/commit/0e9efbfa63a876d80afdba...

Tested on:
Drupal 8.8.1
Metatag latest 8.x-1.x
PHP 7.2 and 7.3
run-tests.sh for running tests

Comments

antongp created an issue. See original summary.

antongp’s picture

StatusFileSize
new38.86 KB

Here is a patch which changes visibility to protected.

Child classes should also be able to override properties like $testTag, $testNameAttribute, etc., so, their visibility also changed to protected.

In addition to properties, "hook" methods like {tag_name}TestKey(), {tag_name}TestValue(), etc., should also be defined as protected (or public) to be invoked from the parent class.

\Drupal\Tests\metatag\Functional\MetatagTagsTestBase::getTestTagName() method visibility needs to be changed as well since it is overridden in several child classes.

\Drupal\Tests\metatag\Functional\MetatagTagsTestBase::randomImageUrl() method visibility needs to be changed too since it is called is some of child classes.

\Drupal\Tests\metatag\Functional\MetatagTagsTestBase::getTestTagValue() doesn't seem to be used or overridden, but its purpose is similar to previous 2 methods, so I think it should not be private too.

\Drupal\Tests\metatag\Functional\MetatagTagsTestBase::getMethodFromTagCallback() method visibility (private) is not changed by the patch.

After fixing visibility, some of tests failed with "Cannot use object of type Behat\Mink\Element\NodeElement as array" error, so I tried to fix this as well (please pay more attention to this change).

Note: the patch does not try to fix tests which assertions fail on run now (just because they weren't executed before), it tries to fix \Drupal\Tests\metatag\Functional\MetatagTagsTestBase base class and visibility of properties and methods in child classes.

Another base class \Drupal\Tests\metatag\Functional\MetatagFieldTestBase doesn't seem to have such issues. Didn't check other classes in details though.

antongp’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 3110152-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

damienmckenna’s picture

Let's fix this for the next release.

damienmckenna’s picture

@antongp: Thanks for uncovering this and putting the patch together, it's appreciated.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new3.95 KB
new39.57 KB

This fixes the tests for the primary module, the submodules still need to be fixed.

Status: Needs review » Needs work

The last submitted patch, 7: metatag-n3110152-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

damienmckenna’s picture

One down, 11 more to go!

damienmckenna’s picture

Assigned: Unassigned » damienmckenna

Working on this some more.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new10.83 KB
new44.68 KB

Let's see how close this is.

damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community

Woohoo!

damienmckenna’s picture

Assigned: damienmckenna » Unassigned
Status: Reviewed & tested by the community » Fixed

Committed. Thanks @antongp!

damienmckenna’s picture

Assigned: damienmckenna » Unassigned
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

antongp’s picture

Hi @DamienMcKenna

Sorry for late question, but I've just noticed that testTagsInputOutput() method was renamed to _testTagsInputOutput() (with underscore) in the commit. Not sure, but did this happen by intent or by accident?

Thanks in advance!

damienmckenna’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new596 bytes

Whoops! Yes indeedy, I temporarily disabled that test while working on the fix but forgot to reenable it.

Let's reenable it.

Status: Needs review » Needs work

The last submitted patch, 18: metatag-n3110152-18.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

damienmckenna’s picture

Per @quietone:

MigrateSqlSourceTestCase is deprecated. Use `Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase` and you can set the expected_count. Maybe looking at core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d7/VariableTranslationTest.php will help.

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new12.15 KB

Moving the tag iteration to a dataProvider. This will blow up the total run time, but it might help pinpoint the points of failure to specific tags.

og_image tag just took away 20GB of disk space locally and then crashed, so that might be one :D

Status: Needs review » Needs work

The last submitted patch, 21: 3110152-21.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new2.05 KB
new12.99 KB

Oh! Nice! That's fantastic, thank you!

This fixes the metatag_open_graph_products tests.

Status: Needs review » Needs work

The last submitted patch, 23: metatag-n3110152-23.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

damienmckenna’s picture

Assigned: Unassigned » damienmckenna
damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new3.71 KB
new16.7 KB

Let's see if this works. In the interest of time I some specific meta tags that we can deal with separately.

damienmckenna’s picture

I created #3122948: Fix @todo notes in tag test files as a follow-on for finishing some of the individual tags that were broken.

damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thank you so much, Lendude, for helping, that made it significantly easier to find the problems.

  • DamienMcKenna committed b1123a4 on 8.x-1.x authored by Lendude
    Issue #3110152 by DamienMcKenna, antongp, Lendude: testTagsArePresent()...
damienmckenna’s picture

Assigned: damienmckenna » Unassigned
lendude’s picture

Happy to help :)

Status: Fixed » Closed (fixed)

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