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.
See #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase)
Proposed followups:
- \Drupal\views\Tests\FieldApiDataTest needs FieldTestBase so omitting from this patch
- \Drupal\views\Tests\ViewAjaxTest needs to be moved to a javascript test #2876209: Convert \Drupal\views\Tests\ViewAjaxTest to a BrowserTestBase test
- \Drupal\views\Tests\ViewElementTest needs to be changed to a kernel test #2876210: Convert \Drupal\views\Tests\ViewElementTest and \Drupal\views\Tests\Plugin\StyleGridTest to kernel tests
\Drupal\views\Tests\Plugin\StyleGridTest
needs to be changed to a kernel test #2876210: Convert \Drupal\views\Tests\ViewElementTest and \Drupal\views\Tests\Plugin\StyleGridTest to kernel tests- All Update tests need UpdatePathTestBase to be converted first
\Drupal\views\Tests\Plugin\StyleOpmlTest
weird stuff happens when not working with HTML (or something, didn't dig deep) #2876211: Convert \Drupal\views\Tests\Plugin\StyleOpmlTest and \Drupal\views\Tests\Plugin\DisplayFeedTest to PHPUnit tests- \Drupal\views\Tests\Plugin\DisplayFeedTest is also using non-HTML pages so taken that out of this conversion #2876211: Convert \Drupal\views\Tests\Plugin\StyleOpmlTest and \Drupal\views\Tests\Plugin\DisplayFeedTest to PHPUnit tests
- Created #2865336: Add \Drupal\simpletest\WebTestBase::assertBlockAppears to \Drupal\FunctionalTests\AssertLegacyTrait,
Notes:
- \Drupal\views\Tests\ViewTestData not sure if we want to move this, so leaving it alone for now.
- Updated
\Drupal\Tests\views\Functional\ViewTestBase::helperButtonHasLabel
to work with BTB (was using field to find a button, that doesn't work) - \Drupal\Tests\views\Kernel\Handler\AreaEmptyTest was split from
\Drupal\Tests\views\Functional\Handler\AreaTest
because it needed to be a kernel test and that required some changes to the methods used for testing. \Drupal\Tests\views\Kernel\Plugin\ExposedFormRenderTest
split of from\Drupal\Tests\views\Functional\Plugin\ExposedFormTest
because it needed to be a kernel test- \Drupal\Tests\views\Kernel\Plugin\DisplayPageTest::testReadMore split from \Drupal\Tests\views\Functional\Plugin\DisplayTest and turned into a kernel test and added to \Drupal\Tests\views\Kernel\Plugin\DisplayPageTest (that sounded like the right place to put it)
Comment | File | Size | Author |
---|---|---|---|
#29 | 2863267-29.patch | 109.37 KB | Lendude |
#29 | interdiff-2863267-25-29.txt | 5.52 KB | Lendude |
#25 | 2863267-25.patch | 108.8 KB | Lendude |
#25 | interdiff-2863267-22-25.txt | 765 bytes | Lendude |
#22 | 2863267-22.patch | 108.8 KB | Lendude |
Comments
Comment #2
LendudeComment #3
LendudeFirst roll, it's a work in progress.
Some points:
\Drupal\views\Tests\ViewAjaxTest
probably needs to be moved to a javascript test\Drupal\views\Tests\FieldApiDataTest
needs FieldTestBase\Drupal\views\Tests\ViewTestData
not sure if we want to move this, so leaving it alone for now.Comment #5
LendudeClean up to hopefully get this green. Still only a partial conversion and still very much a work in progress.
Some more points:
\Drupal\views\Tests\ViewElementTest
probably needs to be changed to a kernel test\Drupal\Tests\views\Kernel\Handler\AreaEmptyTest
was split from\Drupal\Tests\views\Functional\Handler\AreaTest
because it needed to be a kernel test and that required some changes to the methods used for testing.Comment #6
dawehnerI so like this
$row->find()
vs.$row->findAll()
I am wondering whether improving the selectors, like by registering an additional SelectorInterface would make this part unneeded.
Nice!
Keep in mind that we can allow create followups to keep patches reviewable.
Comment #7
LendudeThanks @dawehner for the feedback.
Converted everything I think doesn't need a follow up, locally green, lets see how it does here.
If we agree on the proposed follow ups in the IS, then this would be ready for a full review.
Notes:
\Drupal\Tests\views\Kernel\Plugin\ExposedFormRenderTest
split of from\Drupal\Tests\views\Functional\Plugin\ExposedFormTest
because it needed to be a kernel test\Drupal\Tests\views\Functional\ViewTestBase::helperButtonHasLabel
to work with BTB (was using field to find a button, that doesn't work)\Drupal\views\Tests\Plugin\StyleOpmlTest
weird stuff happens when not working with HTML (or something, didn't dig deep)Nice to know: When casting NodeElement to string using (string) it will just give a 'can't cast to sting' error, but when using the raw NodeElement in an assertion it will throw a 'can't serialise Closure' exception when running the test with no indication where that happens (and no closure anywhere in the test). Knowing that might help people when converting, threw me a bit at first :)
Comment #8
LendudeQuick Self review:
This needs to go. Might be nice to add at some point to the BTB version of ViewTestBase but definitely not on the WTB version
wrap at 80 characters
Comment #9
jofitz CreditAttribution: jofitz at ComputerMinds commentedAlso removed 4 unused
use
statements from AreaEmptyTest.Comment #11
Lendude\Drupal\views\Tests\Plugin\DisplayFeedTest
is also not using HTML output and the browsertestbase is not playing nice with that, so taking it out of the conversion for now and adding it to the follow upsComment #13
LendudeAnd now with the right patch.....
Comment #14
jofitz CreditAttribution: jofitz at ComputerMinds commentedThere is also another unused
use
statement, this time in ExposedFormTest.Comment #15
Lendude@Jo Fitzgerald a 107Kb patch and that's all you got for me :D, thanks for taking a look at it!
Comment #16
jofitz CreditAttribution: jofitz at ComputerMinds commented@Lendude your work is so good it's hard to find flaws (even in 107Kb)! :)
Comment #17
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedI took another stab at the review, found some things I have questions about. No no-go's so I'm not setting it back to needs work. I'll let you be the judge in that :)
If we're changing the label anyway could we also drop the t()?
Same here.
Is $page->findField() possible here or are you also searching for buttons?
Wow ok, nice change. Would never have guessed that one myself..
It seems weird without really knowing what's going on :)
Is this ever going to fail?
This is used multiple times. Would be nice to have it on the base class some day..
I'm not really against embedding the renderRoot() call here but previously you did it before the setRawContent. Any reason for the change?
Comment #18
klausilooks like the method constructFieldXpath() is missing on our AssertLegacyTrait? I think we should open an issue to add that method and a little test in AssertLegacyTraitTest.
Nice change!! getAllOptions() accepts SimpleXML, so I think it does not make sense to add it on AssertLegacyTrait. This is probably the best way to convert this.
why does this class exist if it is just extending the parent class? Please add a comment.
this does not look right. We need to fix this test properly, it should not throw exceptions, right?
So we need a separate issue to add assertBlockAppears to AssertLegacyTrait.
why do we need to change this? Shouldn't this work with assertFieldByXpath()?
And another empty base class. I don't think we should introduce those. We can just tell people on the deprecated classes to use the new ViewTestBase instead?
gahh, git should detect this file as copy. Can you create the next patch with git diff --find-copies harder or -M5% or something?
That change looks wrong. The assertion should be that the element is not empty?
Comment #19
LendudeThanks so much for the feedback both!
@michielnugter those sound like valid points, will look at #17.5, no idea what's going on there.
@klausi some quick feedback on your feedback
#18.1 yeah it's missing, but it seemed like a silly helper method anyway, so that's why i figured I'd just move that logic straight into the test.
#18.3 and #18.7 The empty classes existed before so I went for the 1:1 port, but just leaving them out and extending ViewTestBase directly works for me.
#18.4 It's a debug statement actually, tim.plunkett already opened an issue on this #2853359: Runtime debug statement in Views now prints out object, but for now, yeah this is the expected behaviour, so the test is accurate
will get to work on the rest!
Comment #20
LendudeAddressed feedback:
$this->getSession()->getPage()->findAll('named', ['field', $relationship_name]);
to get rid of the xpath query.Lets see what I broke....
Comment #22
LendudeOne use statement missing, not sure why interdiff is showing more changes.
Comment #23
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedThe implementation changed from an exact name to a partial name (default behavior or findAll('named'). I think you should use named_exact here.
It seems to me the classes are searched for on the div now, before the class was searched on the A tag right?
Is it still correct like this and shouldn't we still search on the A tag to keep the test the same?
Same goes for the other similar changes.
Comment #24
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedUpdate on 3.: I moved WizardTest out of this scope and into #2867777: Convert views WizardTestBase tests to phpunit
Comment #25
Lendude#23.1 fixed
#23.2 that was the test with the return at the top, so that was never run in the old webtestbase version (manually tested this and it's indeed never run, and fails if you take the return out)
#23.3 covered by your follow up
Comment #27
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedPassed after the last run. Looks like it's ready for RTBC to me!
Comment #28
dawehnerI'm wondering whether it would be easier for some potential contrib modules to convert test coverage in case there would be such a parallel test, but well, the trigger_error clearly describes what is going on.
Are you sure setting multiple excepted exceptions works? #18.4 was not addressed. I guess this is not RTBC ...
Comment #29
LendudeThanks @dawehner
#28.2 yeah sorry, misunderstood how
setExpectedException()
works. So I added a properly configured style there to not trigger the debug call. Also added some more fixes to that test further along because that was never run because of the setExpectedExceptioninterdiff shows extra stuff again, only made changes to DisplayTest()
Comment #30
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedGood one @dawehner, I misunderstood that one. And good that it uncovered that a part of the test didn't run.
Preventing the Exception in the first place sounds like a solid fix to me. Code looks good to me, I'm going for RTBC again. Hope I didn't mis anything this time :)
Comment #31
dawehnerLooks good for me now!
Well you know, that's the thing. This entire RTBC thing is a fair assumption, but in reality you simply need to look at stuff from different angles / fresh eyes.
Comment #32
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedIt is postponing a lot of issues in the conversion queue, setting to Major because of that.
Comment #33
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #34
catchCommitted/pushed to 8.4.x, thanks!
Comment #36
dawehnerThanks a ton catch!!!!!!
Comment #37
Mile23A little bit of a follow-up: #2876145: ConfigTranslationViewListUiTest is a WTB test in the Functional namespace
Comment #38
LendudeAdded followups to the IS
Comment #40
catchCherry-picked to 8.3.x too, thanks!
Comment #41
Lendude@catch thanks!