See #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase)

All tests are in scope here.

MenuLinkContentTranslationUITest will use \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase that is not used anywhere in core yet. And this turned up some problems in that class that needed to be fixed.

Comments

michielnugter created an issue. See original summary.

michielnugter’s picture

Status: Active » Postponed
michielnugter’s picture

michielnugter’s picture

Issue summary: View changes
Status: Postponed » Active
snetcher’s picture

Status: Active » Needs review
StatusFileSize
new2.07 KB

Status: Needs review » Needs work

The last submitted patch, 6: 2870451-6.patch, failed testing.

dawehner’s picture

Thank you for your contribution!

You can solve the remaining test failures.
Here is an example:

    $this->assertTrue($element, 'A default menu parent was found.');
    $this->assertEqual('admin:', $element[0]['value'], '<Administration> menu is the parent.');

and use
$element[0]->getAttribute('value') instead.

snetcher’s picture

Status: Needs work » Needs review
StatusFileSize
new921 bytes
new7.03 KB

There's special method getValue()

dawehner’s picture

There's special method getValue()

Cool

Status: Needs review » Needs work

The last submitted patch, 9: 2870451-9.patch, failed testing.

snetcher’s picture

Status: Needs work » Needs review
StatusFileSize
new2.59 KB

#9 patch was wrong, proper one

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

core/modules/menu_link_content/src/Tests/MenuLinkContentTranslationUITest.php is the only remaining test.

michielnugter’s picture

Component: phpunit » menu_link_content.module
Issue tags: +phpunit initiative
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
/**
 * Tests the Content Translation UI.
 *
 * @deprecated Scheduled for removal in Drupal 9.0.0.
 *   Use \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase instead.
 */
abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {

So we can actually convert all tests.

michielnugter’s picture

Issue summary: View changes

@alexpott, very nice that we can convert the whole module at once now!

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new690 bytes
new3.45 KB

Here is the conversion

andypost’s picture

StatusFileSize
new3.51 KB
new939 bytes

proper namespace & interdiff against #12

The last submitted patch, 17: 2870451-menu_link_content-17.patch, failed testing.

The last submitted patch, 18: 2870451-menu_link_content-18.patch, failed testing.

andypost’s picture

StatusFileSize
new1.17 KB
new4.68 KB

Another round

claudiu.cristea’s picture

+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
@@ -229,7 +229,7 @@ protected function doTestTranslationOverview() {
+        $this->assertEqual($elements[0]->getText(), t('Edit'), format_string('Edit link correct for %language translation.', ['%language' => $langcode]));

Shouldn't we remove deprecated format_string() if we already touched this line?

Status: Needs review » Needs work

The last submitted patch, 21: 2870451-menu_link_content-21.patch, failed testing.

michielnugter’s picture

@claudiu.cristea

We've tried to keep the changes as minimal as possible with the conversions to ease reviewing. After all the conversions are done we'll likely need to convert all deprecated code (though that might be targeted on the 9.x branch).

As the format_string() is still used all over the place I'm in favor of keeping it as is for now and convert all of them to a sprintf in one go for the tests later on.

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new1.82 KB
new5.33 KB

@claudiu.cristea thanx, good point!

now patch fixes both places!

btw MenuLinkContentTranslationUITest is the first test class that using abstract class ContentTranslationUITestBase

akashkrishnan01’s picture

Did a quick test, patch is getting applied successfully

lendude’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Bit of a shame we need to fix a base class in a different module for this, but the changes seem straightforward enough so I'm in favour of fixing that here and not in a separate issue first.

Applied the patch, checked the moves and everything looks good!

Updated the IS to include @andyposts findings on \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 25: 2870451-menu_link_content-23.patch, failed testing.

andypost’s picture

Status: Needs work » Reviewed & tested by the community
dawehner’s picture

Nice conversion

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed e2b46f1 to 8.4.x and 4b857af to 8.3.x. Thanks!

So yeah that base class is super interesting because at the moment we have to maintain both base classes. I was about to file a patch to remove the functional one because nothing was using it. Imo we should have converted all the WTB that use ContentTranslationUITestBase at the same time - but stuff is tricky. At least with this patch we finally have a single usage.

  • alexpott committed e2b46f1 on 8.4.x
    Issue #2870451 by andypost, snetcher, michielnugter, dawehner: Convert...

  • alexpott committed 4b857af on 8.3.x
    Issue #2870451 by andypost, snetcher, michielnugter, dawehner: Convert...
dawehner’s picture

So yeah that base class is super interesting because at the moment we have to maintain both base classes. I was about to file a patch to remove the functional one because nothing was using it. Imo we should have converted all the WTB that use ContentTranslationUITestBase at the same time - but stuff is tricky. At least with this patch we finally have a single usage.

I think what we should aim for is a good momentum of test conversion. When things are not 100% perfect in between it matters much less. Note: Test falls under different rules than normal code.

akashkrishnan01’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.