Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Status: Active » Needs review
FileSize
45.37 KB

Ok, bunch of special cases here, will explain in follow-up comment.

Berdir’s picture

  1. +++ b/modules/webform_options_limit/tests/src/Functional/WebformOptionsLimitTest.php
    @@ -90,11 +90,11 @@ class WebformOptionsLimitTest extends WebformBrowserTestBase {
     
         // Check that table select single is available.
    -    $this->assertNoFieldById('edit-options-limit-tableselect-multiple-x', 'X');
    +    $this->assertSession()->fieldNotExists('edit-options-limit-tableselect-single-x');
         $assert_session->responseContains('<td>X</td>');
    

    classic not exists assert problem. this is about the single select based on the verbose output (only that has X, but it was looking for a multiple form element.

  2. +++ b/src/Breadcrumb/WebformBreadcrumbBuilder.php
    @@ -75,7 +75,7 @@ class WebformBreadcrumbBuilder implements BreadcrumbBuilderInterface {
         $route_name = $route_match->getRouteName();
         // All routes must begin or contain 'webform.
    -    if (strpos($route_name, 'webform') === FALSE) {
    +    if (!$route_name || strpos($route_name, 'webform') === FALSE) {
           return FALSE;
         }
     
    

    the unit test (which is incorrectly in the kernel namespace) defines cases with route name NULL. I'm not if that could really happen outside of the test.

    Note that php deprecations in kernel and unit test are suppressed deprecations, while they are not in web tests.

  3. +++ b/tests/src/Kernel/WebformConditionTest.php
    @@ -59,8 +59,9 @@ class WebformConditionTest extends EntityKernelTestBase {
     
         // Test Constructor injection.
    -    $condition = $manager->createInstance('webform', ['webforms' => ['test' => 'test'], 'context' => ['webform' => $webform]]);
    -    $this->assertTrue($condition->execute(), 'Constructor injection of context and configuration working as anticipated.');
    +    $condition = $manager->createInstance('webform', ['webforms' => ['test' => 'test']])
    +      ->setContextValue('webform', $webform);
    +    $this->assertTrue($condition->execute(), 'Constructor injection of configuration working as anticipated.');
    

    passing in context as configuration is deprecated. It's also not webform specific code. IMHO this does not need to be tested at all, not your responsibility, but I just did the minimal change.

  4. +++ b/tests/src/Unit/Utility/WebformOptionsHelperTest.php
    @@ -102,7 +102,6 @@ class WebformOptionsHelperTest extends UnitTestCase {
       public function providerConvertOptionsToString() {
         $tests[] = [[99 => 99], ['99' => 99]];
    -    $tests[] = [[99.11 => 99], ['99' => 99]];
         $tests[] = [[TRUE => 99], ['1' => 99]];
         return $tests;
    

    this is a fun one. you can't have float array keys. this was implicitly casted to an integer, ergo the same key as above. php 8.1 triggers a deprecation message for this:

    https://3v4l.org/bAiUD

Berdir’s picture

Fixing a bunch more deprecations, field widget alter, some assert methods, mime encoding (learned today that there is a neat helper class in Symfony for this)

There are a handful of special deprecations that I'll document in #3262067: [META] Make Webform compatible with Drupal 10. With all the patches combined as done in the test MR there, the only remaining fails that I see are related to/blocked by other contrib modules..

This did become a bit bigger than I expected.

jrockowitz’s picture

Title: Test and one-off D10 deprecations » [Drupal 9.4.x+] Test and one-off D10 deprecations
jrockowitz’s picture

I am going to review the patch and see what can backported to 6.1x.

jrockowitz’s picture

@Berdir Thanks for the patch.

I can't interdiff the backport.

But the only change removed were to ::setUp ::tearDown and protected $modules

daniel_j’s picture

This patch builds on the one in #4. It makes the necessary changes to the .info.yml files so that testing against Drupal 10 can begin in earnest.

The following caveats apply:

  • I did not update the .info.yml files for modules marked DEPRECATED.
  • I attempted to update the Javascript to use the new Drupal once API. However, I was not sure how to proceed with webform.element.computed.js since its logic is a bit more convoluted, and I am still a newbie at using once.

In light of the above, this by no means should be considered a final patch. But it might be a step in the right direction.

Berdir’s picture

This is a part of a meta issue for D10 compatibility, there are already issues for once for example and a number of other changes.

jrockowitz’s picture

Status: Needs review » Postponed

One-off fixes will need to be addressed after major issues are fixed.

Berdir’s picture

what major issues? :) IMHO #4 is ready and other D10 issues aren't really more important, this is just stuff that couldn't really be grouped in a useful way in separate issues IMHO

Berdir’s picture

Here's a reroll of #4.

Berdir’s picture

Status: Needs review » Needs work

Hm, that reroll is outdated, looks you committed stuff from rector that's a bit different than this? A bit confused by that :) Several of the conflicts here were actually cleaned up and simplifed in this patch, for example:

++<<<<<<< HEAD
 +      $destination = \Drupal::service('stream_wrapper_manager')->normalizeUri(\Drupal::config('system.file')->get('default_scheme') . ('://' . $file_system->basename($csv_file_path)));
++=======
+       $destination = 'public://' . $file_system->basename($csv_file_path);
++>>>>>>> 982ccbef3 (one-off deprecations #3296068)

No need to use a config or normalize a hardcoded destination in a test.

Berdir’s picture

Here's a reroll, kept some of my improvements from the conflicts, see conflicts file. Not sure if you misunderstood the scope of this issue, would have been easier to commit this first and then run rector to see if I missed something?

As you can see, there about 24kb of the original 60kb left here.

jrockowitz’s picture

Status: Needs review » Fixed

  • 038bbfa committed on 6.2.x
    Issue #3296068 by Berdir, jrockowitz, daniel_j: [Drupal 9.4.x+] Test and...

Status: Fixed » Closed (fixed)

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