Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GoZ created an issue. See original summary.

GoZ’s picture

Status: Active » Needs review
FileSize
14.18 KB

Patch does not convert all tests yet. Some work has to be done to complete this.
Tests importing configuration use DrupalPostAjaxForm() and should be converted to Javascript test base.

Status: Needs review » Needs work

The last submitted patch, 2: convert_web_tests_to-2864026-2.patch, failed testing.

GoZ’s picture

Status: Needs work » Postponed

Fail because of wtb assertCacheContext(). Postponed, waiting after #2795085: Add assertNoCacheTag to assertLegacyTrait commit.

michielnugter’s picture

Issue tags: +phpunit initiative

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jonathan1055’s picture

Status: Postponed » Needs work

#2795085: Add assertNoCacheTag to assertLegacyTrait is in, so un-postponing this.

I am interested to hear yout thoughts on converting ConfigSingleImportExportTest::testExport() because it contains a call to getAllOptions() which was in Drupal\simpletest\AssertContentTrait but has not yet been moved into Drupal\FunctionalTests\AssertLegacyTrait (or to anywhere, infact). I need this function for converting WizardTest in #2866513-51: Convert web tests to browser tests for comment module

I tried copying it into AssertLegacyTrait but the calling code needs some slight conversion, as the parameter $element from xpath is of the wrong class to that expected in the function definition.

Lendude’s picture

For ease of conversion/BC we might want to add getAllOptions() to AssertLegacyTrait, in that case we should open an issue for it and postpone on that, but....
It's not used a lot, and I think it can be replaced by a one liner:

    $options = $element[0]->findAll('xpath', '//option');

So is it really worth it? IMO it's also one of those methods that you would never look for if you didn't know it existed, so anybody not intimately familiar with the available methods would just use that one liner anyway.

jonathan1055’s picture

Thanks Lendude. Yes, I spent some time trying to figure out how to get the options list, and was very pleased to discover the ->findAll() method and get the test working before I saw your comment.

With regard to copying/converting getAllOptions() to AssertLegacyTrait, it is only used in core tests in these two places (config and comment). I have searched the 28 modules for 8.x that I have on my local drive and only found it used once, in Token module. Is there a way to run a search on the contrib modules source code on drupal.org?

I agree with you, I think it is not worth converting, and we should just use the direct call to ->findAll(), which is simple and will save adding an extra 25 lines of barely-used code to AssertLegacyTrait. To help others who come along later who are converting tests that use getAllOptions() can we add a general comment in the top of AssertLegacyTrait listing functions and assertions which have not been converted, along with hints or issue links showing the alternatives?

Lendude’s picture

Apparently I did something similar in the Views conversion, not that I remembered, https://www.drupal.org/node/2863267#comment-12014253

it used once, in Token module.

The fact that it's used at all makes me feel that we should add it to AssertLegacyTrait :(
It is also the clearest way to point people towards a better alternative then using the method. Opened #2907485: Add getAllOptions() to AssertLegacyTrait, so we can discuss it there further if needed.

I'd say we don't postpone this though, since it's just a one liner we replace it by, this won't effect the reviewability of the patch

jonathan1055’s picture

It looks like we have duplicate issues for converting the config tests:

#2864026: Convert web tests to browser tests for config module (this issue)
Created on 25 March 2017.
It is a child of #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase) but is not shown on that issue summary.

#2870439: Convert web tests to browser tests for config module
Created 17 April 2017
Also a child of the main issue and is shown in that issue summary. It has a bigger patch with more work done (15 files changed compared to 10).

naveenvalecha’s picture

Issue summary: View changes

I have closed this as duplicate #2870439: Convert web tests to browser tests for config module give credit to @andypost and @valpas for their work in #2870439: Convert web tests to browser tests for config module

jonathan1055’s picture

Issue summary: View changes
Status: Needs work » Closed (duplicate)

Thanks Naveenvalecha, but actually it should be the other way round, so I am closing this one as the duplicate. See my comment in #2870439-26: Convert web tests to browser tests for config module #26 for more details.