Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gbyte.co created an issue. See original summary.

gbyte’s picture

wells’s picture

I have started to look at updating these tests. One thing I ran into immediately is caching issues. E.g. SimplesitemapTest::testSetBundleSettings() fails on the second set of assertions because the the sitemap file is still cached after changing the bundle settings.

Should Simplesitemap::generateSitemap() be invalidating the appropriate cache after it completes? I suspect so, but I'm still a little hazy on the caching changes in Drupal 8. Right now the only place I see specific cache invalidation happening is Simplesitemap::removeSitemap().

gbyte’s picture

Hey wells, you looking into the tests makes me happy.

Fixing them up is the first step; the next step will be creating more of them for the new functionalities in 3.x.

A variant's cache should be invalidated upon its deletion. Now that generation has been streamlined, I have just pushed some code making variants invalidate as soon as they are deleted from the database. The invalidation is called directly in removeSitemapVariant() but only if a published variant is being removed.

I have not tested it, but I hope this fixes the test issues you are having. If not, feel free to comment out the particular test that is not passing and then we can fix the variant caching in this issue: #2972131: Cache sitemap on a per variant basis.

Thanks again for your help with the tests!

wells’s picture

Attached is an initial patch that gets things going again. In local testing I am getting the following results:

There were 2 errors:

1) Drupal\Tests\simple_sitemap\Functional\SimplesitemapTest::testRemoveCustomLinks
Behat\Mink\Exception\ExpectationException: The string "http://drupal8.local:8000/" appears in the HTML response of this page, but it should not.

/vendor/behat/mink/src/WebAssert.php:768
/vendor/behat/mink/src/WebAssert.php:339
/tests/src/Functional/SimplesitemapTest.php:107

2) Drupal\Tests\simple_sitemap\Functional\SimplesitemapTest::testSetBundleSettings
Behat\Mink\Exception\ExpectationException: The string "node/1" appears in the HTML response of this page, but it should not.

/vendor/behat/mink/src/WebAssert.php:768
/vendor/behat/mink/src/WebAssert.php:339
/tests/src/Functional/SimplesitemapTest.php:187

--

There was 1 failure:

1) Drupal\Tests\simple_sitemap\Functional\SimplesitemapTest::testRemoveDuplicatesSetting
Failed asserting that 2 is identical to 1.

/tests/src/Functional/SimplesitemapTestBase.php:95
/tests/src/Functional/SimplesitemapTest.php:254

ERRORS!
Tests: 15, Assertions: 179, Errors: 2, Failures: 1.

Errors:

1) It looks like Simplesitemap::removeCustomLinks is working, but Simplesitemap::generateSitemap doesn't do anything if there is nothing to generate (I suspect this should remove the sitemap?).

2) Changing the bundle index setting from TRUE to FALSE does not appear to cause the sitemap to rebuild. Maybe this is also a "nothing to generate" issue?

Failures:

1) The remove_duplicates setting does not appear to be implemented yet.

Once these issues are resolved, I believe the existing tests will pass.

  • gbyte.co committed ca23c0e on 8.x-3.x
    Issue #3000655 by wells, gbyte.co: Fix tests for 3.x
    
gbyte’s picture

Status: Active » Fixed

Thanks. I believe the problem is not the queue rebuilding at it is rebuild when queue is empty. It appears to work outside of the tests without issue, I commented it out for now. Tests are a work in progress anyway.

Status: Fixed » Closed (fixed)

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