Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Comment | File | Size | Author |
---|---|---|---|
#22 | interdiff-22.txt | 2.66 KB | dermario |
#22 | should_be_possible_to-2657776-22.patch | 13.17 KB | dermario |
#18 | interdiff-18.txt | 1.49 KB | dermario |
#18 | should_be_possible_to-2657776-18.patch | 12.87 KB | dermario |
#16 | interdiff-16.txt | 10.91 KB | dermario |
Comments
Comment #2
BerdirRequires a bit more code than I initially expected. We need two confirmation forms, core unfortunately doesn't have defaults.
I'm also adding config_export keys as they were missing and added status to the lookup keys. That requires
Comment #3
BerdirComment #6
gaurav.goyal CreditAttribution: gaurav.goyal at Innoraft commentedI think this patch also needs reroll. Adding Needs reroll tag.
Comment #7
gaurav.goyal CreditAttribution: gaurav.goyal at Innoraft commentedAttached is the rerolled patch.
Comment #8
dermarioThe patch in #7applies well. Thank you! I reviewed the code and tested its functionality. Please see the attached Screens. Looks ok from my side, now i will investigate in writing some tests.
Comment #9
dermarioComment #10
dermarioHere are some tests that check if the pattern workflows are working correctly.
Comment #11
BerdirNice work, feedback below.
Wondering if we really need a separate test class from PathautoUiTest, especially since they have pretty much the same set up.
You might be interested in #2469713: Step 2: Create a JavaScriptTestBase using PhantomJs Driver/Binary.
It actually got committed today but then reverted again due to problems with contrib tests.
However, once this is in, we could actually write real JS tests for this.
Also, you can actually already do write a test that works for this form. See \Drupal\pathauto\Tests\PathautoLocaleTest::testLanguagePatterns.
If you change the add so that it works as in the referenced example, then I'd prefer to merge this into a single test method. Test methods add quite a bit of overhead in web tests
The one thing we don't have covered now is actually checking if a disabled pattern is considered for aliases or not.
We can either do that here in the same UI test and create a node through the UI or API or we can extend PathautoUnitTest and somehow test it there.
Comment #12
dermarioGreat feedback, thank you! I will go for it today.
Comment #13
dermarioHere is a new patch. These are the major changes:
I completely removed src/Tests/PathautoPatternsWebTest.php and moved the logic there into src/Tests/PathautoUiTest.php and src/Tests/PathautoUnitTest.php.
I extended the former PathautoUiTest::testPatternsValidation(), now PathautoUiTest::testPatternsWorkflow() with edit, enable, disable and delete tests and how nodes behave with enabled/disabled patterns.
PathautoUnitTest::testPatternStatus() tests how Nodes behave with enabled, disabled Patterns and when Nodes are saved and edited.
Comment #16
dermarioOk, here is a new patch with (hopefully) working tests. I forgot to clear the pathauto caches \Drupal::service('pathauto.generator')->resetCaches();
The description in #13 is still up to date.
My interdiff refers to the patch in comment #10
Comment #17
BerdirLooks good, just one thing to improve.
the second argument of assertNoEntityAlias() is the language, not the alias.
It checks there there is no alias at all, which is what we want. But right now you actually check for the language '/page-pattern-disabled', which of course doesn't exist. Just remove that.
I would also remove the drupalGet() and $alias completely, we don't want to hardcode how it would be when it doesn't exist.
same here.
Comment #18
dermarioAhh i got tricked by assertEntityAlias() -signature, which is different. This and the other comments in #17 are applied now.
There is one thing i didn't get running and actually don't know if its a bug or of its relevant. Maybe its just a lack of knowledge from my side.
In PathautoUnitTest::testPatternStatus() i wanted to check if an existing Node ($node2) without an alias gets an alias after the pattern was enabled and $node2 was saved. Although i could see the alias was created and stored in database.
As i said before, i removed that code again because i am not sure if that case is relevant.
Comment #21
dermarioComment #22
dermarioThe previous test was failing because i created a duplicate pattern in my test. Now it should work.
Comment #23
BerdirLooks good to me, thanks.
Comment #25
BerdirCommitted and pushed, thanks everyone for the help.