Closed (fixed)
Project:
Metatag
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
23 Mar 2019 at 16:43 UTC
Updated:
22 May 2020 at 01:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
damienmckennaThanks for putting this together!
Let's leave it it postponed for now, we'll come back to it later.
Comment #3
Cary_Dean commentedHere are 44 fixes for the tests. Thanks!
Comment #4
Cary_Dean commentedI am not sure what happened to that patch.
Comment #5
waverate commentedPatch at #4 brings it down to 25 errors.
Comment #6
waverate commentedComment #7
pguillard commentedI updated a few ones, passing from 39 errors to 34...
Comment #8
sershevchykdrupal-check modules/contrib/metatag
400/400 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
[ERROR] Found 34 errors
Comment #9
sershevchykComment #10
sershevchykdrupal-check modules/contrib/metatag
400/400 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
[OK] No errors
Comment #11
sershevchykComment #12
sershevchykComment #13
pixlkat commentedI started with the patch in #12 and fixed the remaining items from the deprecation check I could find. Locally, the only errors I see now from drupal-check are classes which it is unable to autoload. Tests are passing locally.
Comment #14
sershevchykAfter applying patch #13
drupal-check modules/contrib/metatag
400/400 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ --------------------------------------------
Line metatag_app_links/src/Tests/MetatagAppLinksTagsTest.php
------ --------------------------------------------
Class Drupal\Tests\metatag_app_links\Functional\MetatagAppLinksTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ --------------------------------------------
------ --------------------------------------------
Line metatag_dc/src/Tests/MetatagDublinCoreTagsTest.php
------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------
Class Drupal\Tests\metatag_dc\Functional\MetatagDublinCoreTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ --------------------------------------------
------ --------------------------------------------
Line metatag_dc_advanced/src/Tests/MetatagDublinCoreAdvancedTagsTest.php
------ --------------------------------------------
Class Drupal\Tests\metatag_dc_advanced\Functional\MetatagDublinCoreAdvancedTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line metatag_facebook/src/Tests/MetatagFacebookTagsTest.php
------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------
Class Drupal\Tests\metatag_facebook\Functional\MetatagFacebookTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line metatag_favicons/src/Tests/MetatagFaviconsTagsTest.php
------ -------------------------------------------
Class Drupal\Tests\metatag_favicons\Functional\MetatagFaviconsTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line metatag_google_cse/src/Tests/MetatagGoogleCSETagsTest.php
------ -------------------------------------------
Class Drupal\Tests\metatag_google_cse\Functional\MetatagGoogleCSETagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line metatag_google_plus/src/Tests/MetatagGooglePlusTagsTest.php
------ -------------------------------------------
Class Drupal\Tests\metatag_google_plus\Functional\MetatagGooglePlusTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line metatag_hreflang/src/Tests/MetatagHreflangTagsTest.php
------ -------------------------------------------
Class Drupal\Tests\metatag_hreflang\Functional\MetatagHreflangTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line metatag_mobile/src/Tests/MetatagMobileTagsTest.php
------ -------------------------------------------
Class Drupal\Tests\metatag_mobile\Functional\MetatagMobileTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line metatag_open_graph/src/Tests/MetatagOpenGraphTagsTest.php
------ -------------------------------------------
Class Drupal\Tests\metatag_open_graph\Functional\MetatagOpenGraphTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line metatag_open_graph_products/src/Tests/MetatagOpenGraphProductsTagsTest.php
------ -------------------------------------------
Class Drupal\Tests\metatag_open_graph_products\Functional\MetatagOpenGraphProductsTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line metatag_pinterest/src/Tests/MetatagPinterestTagsTest.php
------ -------------------------------------------
Class Drupal\Tests\metatag_pinterest\Functional\MetatagPinterestTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line metatag_twitter_cards/src/Tests/MetatagTwitterCardsTagsTest.php
------ -------------------------------------------
Class Drupal\Tests\metatag_twitter_cards\Functional\MetatagTwitterCardsTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line metatag_verification/src/Tests/MetatagVerificationTagsTest.php
------ -------------------------------------------
Class Drupal\Tests\metatag_verification\Functional\MetatagVerificationTagsTest was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line src/MetatagServiceProvider.php
------ -------------------------------------------
Class Drupal\metatag\MetatagServiceProvider was not found while trying to analyse it - autoloading is probably not configured properly.
------ -------------------------------------------
------ -------------------------------------------
Line tests/src/Kernel/MetatagSerializationTest.php
------ -------------------------------------------
60 Call to deprecated method setExpectedException() of class Drupal\KernelTests\KernelTestBase:
in drupal:8.8.0 and is removed from drupal:9.0.0.
Backward compatibility for PHPUnit 4 will no longer be supported.
------ -------------------------------------------
[ERROR] Found 16 errors
Comment #15
pixlkat commentedInteresting. I did not get that result from drupal-check locally. The deprecated method that shows up in your output is the thing that is causing tests to fail. I am using phpunit 6.5.14 locally and saw the same failure in tests that the bot shows for the patch in #12. I don't really understand why it appears as the method expects a string as the parameter. --
Comment #16
pixlkat commentedI have replaced the PHPUnit 4 compatibility code with what appears to be the appropriate method calls. expectException is expecting a *class* not the message itself.
Comment #17
joshi.rohit100It seems that all the autoloading issues are because of the incorrect namespace.
For example -
The namespace in "MetatagAppLinksTagsTest" class is "namespace Drupal\metatag_app_links\Tests" which looks not correct.
Just not sure if that's in scope of this issue or deserve a new issue.
Comment #18
sershevchykFor all errors, we need to add the folder with name Functional (https://prnt.sc/pbp91n) or update namespace but I don't see the new folder in diff or patch. How we can add this folder?
Comment #19
sershevchykComment #20
damienmckennaSome of the tests were updated in #2820214 and #3073826, but it seems we missed the tests in submodules. Would you mind moving the test changes into a new issue and we can commit it separately? Thank you!
Comment #21
baikho commented@DamienMcKenna, I've created #3084547: Move submodule tests in /tests/Functional folder for that. #19 will need a re-roll afterwards.
Comment #22
sershevchykAfter issue #3084547 we can use this patch
Comment #23
damienmckennaThanks everyone. I'm planning on working on this next week.
One question I have is: what would these changes make in terms of core requirements - would it still work with 8.5 or 8.6?
Comment #24
damienmckennaComment #25
sershevchyk@DamienMcKenna we need to push #3084547 first and then retest my last patch and then we will know how many problems we have
Comment #26
abrammI'm going to check this at DrupalCon Amsterdam 2019.
Comment #27
abrammThe patch #22 doesn't apply against latest 1.x-dev so I'm going to try re-rolling #19.
Comment #28
abrammHere's a re-roll of #19 against latest 8.x-1.x since #22 won't apply.
Comment #29
abrammI'm getting 15 errors with the latest patch applied again 8.x-1.x but they are all related to autoloader.
Comment #30
abrammI've managed to fix 14 of 15 issues from the above. The last one I believe is a soft module dependency so could be safely skipped.
I'm not entirely sure but it's possible that some unit tests weren't ran at all due to incorrect namespaces; at least one of them were referencing a private method of the parent class so obviously it should have been failing.
Attaching the patch and interdiff.
Comment #31
abrammNeeds Review.
2 maintainers: please credit @valthebald for his assistance at the code sprint.
Comment #33
damienmckennaThanks for working on this.
This error is weird:
MetatagVerificationTagsTest.php is in the correct directory, it extends Drupal\Tests\metatag\Functional/MetatagTagsTestBase which extends Drupal\Tests\BrowserTestBase, so it should work?
These two suggest the dependent modules weren't downloaded locally:
Comment #34
abrammHi @DamienMcKenna,
The namespace should have been Drupal\Tests\metatag_verification\Functional and not Drupal\metatag_verification\Tests. Note the 'Functional' is missing and 'Tests' not in correct place.
This is already fixed in #30, please see the interdiff and the latest drupal-check report.
Comment #35
damienmckennaI was writing that while you were working on the improvements; thanks for all of your work on this!
Comment #36
damienmckennaSome of the changes in #30 are just fixes that haven't shown up yet, e.g namespace changes and typos, could those please be split off into their own issue so this one is just focused on the upgrade? Thanks.
Comment #37
berdirThis change is not correct, getChangeList() only returns changes, it doesn't *do* anything. applyUpdates() has been removed without replacement because for the most part, it was misused, here too.
This should never have been done like this as you have no control over what changes are applied. This could mess things up badly as it would have tried to apply changes that it wouldn't have been able to.
Not sure about the first, but 8106() should have been something like rest_update_8201() and explicitly install that entity type (FWIW, I don't understand why we even track config entity types there, that makes no sense at all).
One option would be to just cut off update functions up to and including 8106 and add a hook_update_last_removed(). It's technically already too late for that, because it would fail for someone trying to update from an older version to the latest on Drupal 8.7+, but this update was added 3 years ago, so hopefully nobody has a version that outdated anymore or they'll likely have much worse issues than this ;)
Agreed that the namespace and use fixes on actual classes like these would make sense as a separate issue, a but surprised that this isn't caught by tests.. I assume these kind of group plugins are never actually instantiated, and the discovery still works as it doesn't include the files.
Comment #38
berdir#30 shows that this does indeed fail on 8.6, so no matter when exactly this will be committed, I would recommend to add a core dependency to metatag.info.yml, users might still try to apply this update which would break their site pretty hard. Since the module already depends on drupal:field, you could just change that to
drupal:field (>=8.7)(it doesn't matter which core module you put the dependency on).Alternatively, you could replace
core: 8.xwithcore_version_requirement: ^8.7.7 || ^9. Although there might still be some 8.8 deprecations to take care off. running drupal-check on 8.8 complains about drupal_installation_attempted() and also old web tests (these can already be converted now but I'd recommend a separate issue). Again up to the maintainer whether you'd already want to add || ^9, I sometimes do it anyway as it's a bit of a hen/egg problem otherwise, you actually test against 9.0 without that.Comment #39
gmangones commentedHi, After apply the patch about comment #30 and drupal-check, changed the deprecate function drupal_installation_attempted().
But, need work about what is suggested in the comment comment #37.
Thanks
Comment #40
chr.fritschHere is a separate issue to fix the broken namespace and imports.
#3101288: Fix namespace and imports
Comment #41
berdirLooking into this.
Comment #42
berdirOk, this was more work than expected, as a lot of the deprecations were dynamic and not found by drupal-check. Also the existing patch cheated a bit for example with the migrate unit tests, those were simply skipped due to the empty data source provider, plus they were in the wrong folder.
Knowing @DamienMcKenna, he might want to split this up a bit, lets see ;)
Notes:
* As mentioned, the MigrateSqlSourceTestBase changes are tricky and require complete rewrites of these tests as they are now kernel test, with quite a lot of magic (it knows what to test due to the @covers definition.
* Quite a few entity manager related left-overs that drupal-check didn't see as it used the container, old variable names. Also used the new DI pattern for \Drupal\metatag\Plugin\migrate\source\d7\MetatagFieldInstance which should allow it to work on 8.7 and 8.8 and is less dependant on future changes.
* Added $defaultTheme to a lot of tests, with a @todo in one to remove a chunk of code once this requires at least 8.8 but it will not fail on D9. Also, feels like the tests could be deduplicated quite a bit by extending most of them from a common base class.
* removed the change in metatag_install() as it requires 8.8 and created #3105837: Remove metatag_install().
* As suggested, removed the (very) old update functions and add a last removed hook instead. Several of these would not work anymore in 8.7+, and this seems like the better solution.
* There are also a bunch of overlaps with existing (RTBC) issues, like the new drupal_set_message() calls, class name fix. Should be an easy rebase, but it was helpful to include here to make remaining deprecations easier to see.
Remaining deprecation messages:
AFAICS, except drupal_installation_attempted(), these are all coming from other modules.
Comment #43
chr.fritschJust a reroll
Comment #44
chr.fritschRerolling again
Comment #45
chr.fritschAnother reroll
Comment #46
phenaproximaRerolled on top of #3109835: Declare compatibility with Drupal 9. Until today, I didn't even know this issue existed. But if I had, I would have pushed for this to get in, rather than the other one. Please accept my apology.
Comment #47
chr.fritschYet another reroll.
Comment #48
phenaproximaRerolling again!
Comment #50
damienmckennaScheduling this for the next release.
Comment #51
berdirConsidering how many reroll this needs, it really would be nice to get this in sooner rather than later :)
Fixed the kernel tests, they need the token module enabled now.
Comment #52
phenaproximaAnother freakin' reroll.
Comment #53
berdirthis test is now being added and none is removed.
That's because the same work was done in #3120947: Expand FieldInstanceTest classes to handle multiple bundles per entity type (:() but that added the new class in a different namespace. We need to remove this one and probably also move the other test that still does need to be converted to the same location.
Comment #54
phenaproximaRound and round we go.
I discarded the MetatagFieldInstanceTest added by this patch, in favor of the one added in #3120947: Expand FieldInstanceTest classes to handle multiple bundles per entity type. Having looked both of them over, I think they're basically identical in coverage, except that the one added last night is more "realistic" because it doesn't do as much service mocking. So, let's just stick with that.
Comment #55
damienmckennaI'm working on removing the dependencies that don't have D9-compatible releases, so that composer can run without throwing errors.
Comment #56
damienmckennaI've removed Devel, RestUI and Schema.org Metatag as dependencies, let's see if that's enough for this to get past Composer.
Comment #57
berdirRequested a test run with PHP 7.3 instead, D9 needs that.
That said, I wouldn't really recommend to remove those dependencies/tests, because you also lose the test coverage on 8.x for those integrations then. Lets just try to push them all along together, devel apparently did a quite a bit of preparation already, just not that part yet, seems to have active maintainers and the other two afaik have patches that we just need to get committed.
But that's up to you :)
Comment #58
berdirLooks like the patch no longer applies as you removed those tests :)
Also, for restui, do you really need the UI for a test? Aren't you just trying to test an actual REST service/normalization, then you could set that up through the API and skip the module?
Comment #59
damienmckennaThe tests that were removed will be added back again once those modules are D9 compatible, see #3123578: Add NodeJsonOutput test back again, #3123583: Add Devel dependency, tests back again and #3123521: Add Schema.org Metatag dependency, tests back again.
Comment #60
phenaproximaAnother reroll in light of recent commits.
Comment #61
phenaproximaConverted NodewordsFieldTest to a kernel test.
Comment #62
phenaproximaThis should fix MetatagAppLinksTest. Worked locally for me, anyway...
Comment #63
phenaproximaThis should reduce the failures. After this, I suspect the remaining ones are originating in other modules...
Comment #64
phenaproximaLet's see if using the HEADs of Page Manager and Redirect produce a positive effect.
Comment #65
berdirEverything except the page manager test passes now and I verified locally that it passes when combined with #3109618: Fix tests on Drupal 9 and drop support for 8.7 and earlier.
So I think this is as ready as it can be!
Comment #66
phenaproxima#3109618: Fix tests on Drupal 9 and drop support for 8.7 and earlier is in!
Comment #67
chr.fritschpage_manager is already released. I think it's better to use ^4.0-beta5 instead of requiring the dev.
Comment #69
damienmckennaCommitted! Thank you so much, everyone! This is fantastic!
BTW I'm completely ok relying on dev releases of modules that are only used as test dependencies, if we want to tighten that up later we can do that but for now it's fine.
Comment #70
damienmckennaOne quick follow-up: this breaks compatibility with Drupal 8.7, would adding the
core: 8.xline back into the info.yml files break compatibility with D9? Putting it another way: is it possible to make it compatible with 8.7, 8.8 and 9.0?Comment #71
berdirYou can't mix ^8.7.7 and core: 8.x, and that's not actually the problem.
One problem is that the constructor of NodewordsFieldInstance was adjusted to use EntityTypeManager, instead, the approach I took in the other migrate class should be used here as well, with assigning things in create(), then we don't have to require 8.8.
The other fails are I think only caused by having page_manager in the test environment, both core and core_version_requirement were removed there in test modules, which is only supported since 8.8.2 or so. page_manager requires 8.8 now, so it doesn't care, but it also affects metatag now. Best we could do is add them back in -dev there to explicitly require 8.8 instead of relying on the new magic. At least the page manager test is still going to fail on 8.7 though.
Comment #72
damienmckennaOk, thank you for taking the time to look into all of the errors. I'll run the main tests locally against 8.7 before the next release, just to be sure.
Comment #73
berdirCopied over the DI approach from MetatagFieldInstance, page_manager has been updated, so this should now pass on 8.8, 9.0 and mostly on 8.7 too. I think I commented earlier that you already before had some failing tests on 8.7 due to label changes in core, lets see.
Comment #75
damienmckennaCommitted. Thanks again.
Comment #77
kristen polI was looking at the usage of
core_version_requirementfor various projects and see that the committed code used quotes around the versions whereas all the other projects I've reviewed so far (about 50) do not use quotes and the change record doesn't use quotes.https://git.drupalcode.org/project/metatag/blob/ec6ee0e96b959d4eff276101...
Change record: https://www.drupal.org/node/3070687
Although this technically works, I would suggest updating it at some point to not include the quotes for consistency with other projects.