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.
Follow up to #2863267: Convert web tests of views
Convert \Drupal\views\Tests\Plugin\StyleOpmlTest and \Drupal\views\Tests\Plugin\DisplayFeedTest to PHPUnit tests. Both these tests use a non-HTML page, so special steps need to be taken to account for that.
Comment | File | Size | Author |
---|---|---|---|
#17 | 2876211-17.patch | 7.48 KB | Lendude |
#17 | interdiff-2876211-15-17.txt | 449 bytes | Lendude |
#15 | 2876211-15.patch | 7.41 KB | Lendude |
#3 | 2876211-3.patch | 8.19 KB | Lendude |
Comments
Comment #2
LendudeComment #3
Lendude$this->getSession()->getDriver()->getAttribute() / $this->getSession()->getDriver()->getText() seems like the way forward here.
Comment #4
dawehnerI'm wondering whether really relying on these methods is the right idea. Maybe parsing the XML explicit is the right way to go.
Comment #5
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedI actually think this is ok (at least for now). If we decide this is not the way to test XML responses we should do a follow-up, we should ask the rest maintainers I think as they deal with non-HTML responses I can imagine.
For this issue: This is about converting it as directly as possible and currently this is the only method to use Mink to get to a non-//html element (that I know of).
Review:
Could we use:
$element = $this->getSession()->getDriver()->find('xpath');
here and getAttribute on the returned NodeElement? Would make it a little more efficient and more similar to what it was.
Comment #6
dawehnerIn general I prefer explicitness over implicitness, so parsing XML explicit rather than relying that it sort of works, feels better.
Comment #7
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedDiscussed with @lendude offline and we agreed that finding out the proper way of testing an XML response is in scope for this issue as it's already a follow-up.
Let's figure it out. Maybe we should talk/borrow from the rest team.
Comment #8
dawehnerSure, you know, we can always iterate later.
Comment #9
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedMight this issue be an interesting way to go forward for this?
#2812967: API test base: Provide a test helper to test REST and similar APIs
Comment #10
dawehnerYou are right, it would be probably a potential usage for it.
Comment #11
LendudeOk lets postpone on #2812967: API test base: Provide a test helper to test REST and similar APIs for now, using something like that would certainly be the best way to go.
Comment #15
LendudeReroll.
If we ever get an API to better test XML stuff, we can always refactor this test to use then, lets not wait for that. Until then, this works, right?
Implemented feedback from #5 (better late then never :D)
Comment #17
LendudeWhoops
Comment #18
dawehnerI really like the better API
Comment #19
alexpottCommitted and pushed 5f2605fe4c to 8.7.x and 6ddb9ed89b to 8.6.x. Thanks!
FYI This is better written as
assertContains()
but let's not delay on such improvements.