Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave created an issue. See original summary.

longwave’s picture

Status: Active » Needs review
FileSize
18.64 KB

Status: Needs review » Needs work

The last submitted patch, 2: 3097892.patch, failed testing. View results

mondrake’s picture

We cannot remove PhpunitCompatibilityTrait yet because the assertEquals override implemented in the PhpunitVersionDependentTestCompatibilityTraits is still needed.

I see 3 options:

longwave’s picture

The PHPUnit 4 bridge code in core/tests/bootstrap.php can be removed here too, I think.

mondrake’s picture

#5 +1

Edit: actually there is #3063182: Remove PHPUnit 4.8 class aliasing BC layer for that

mondrake’s picture

longwave’s picture

Status: Needs work » Needs review
FileSize
26.84 KB
8.17 KB

#3082340: Replace assertEquals() overrides in PHPUnit Kernel, Functional and FunctionalJavascript tests with a MarkupInterfaceComparator implementation is in so let's try again. Missed some of the PHPUnit compatibility stuff before, so some additions in this patch.

The last submitted patch, 8: 3097892-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mondrake’s picture

Assigned: Unassigned » mondrake

On this.

mondrake’s picture

Assigned: mondrake » Unassigned
FileSize
33.8 KB
6.85 KB

More removals / fixes.

mondrake’s picture

Some more leftovers.

longwave’s picture

+++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
@@ -690,22 +690,6 @@ protected function assertPattern($pattern) {
-   * Deprecated Scheduled for removal in Drupal 10.0.0.

I don't think these should be removed until Drupal 10 (even if the trigger_error() says Drupal 9) as these were un-deprecated in #3031580: Undeprecate \Drupal\FunctionalTests\AssertLegacyTrait and \Drupal\KernelTests\AssertLegacyTrait in Drupal 8

mondrake’s picture

Status: Needs review » Needs work

Aha so those are needed for running Simpletest tests... I guess we need to remove the trigger_errors for now, then, to avoid such confusion. Bad chance it was not done in the other issue.

edit - we need to remove the expected deprecation in tests, too

mondrake’s picture

Status: Needs work » Needs review

Doing #14 or whatever it needs there can be controversial, so I propose to tackle that separately. Re-uploading #11, which is good to go IMO

mondrake’s picture

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

> Aha so those are needed for running Simpletest tests...

No, not for simpletest tests. For tests that have been converted from simpletest to phpunit without updating all those asserts. It was decided to push the deprecation back to D10 as the cost if keeping it is low and the amount of calls to those is massive.

Bunch of comments below, but nothing actionable, just some notes, so I think this is ready. Kind of expected this to remove old simpletest base classes in modules, but this is just about the testing component, makes sense.

  1. +++ b/core/modules/system/tests/src/Functional/Entity/Update/SqlContentEntityStorageSchemaConverterTestBase.php
    @@ -124,7 +124,7 @@ public function testMakeRevisionable() {
     
           // Check that the correct initial value was provided for the
           // 'revision_translation_affected' field.
    -      $this->assertTrue($revision->revision_translation_affected->value);
    +      $this->assertTrue((bool) $revision->revision_translation_affected->value);
    

    Ah, these are legacy tests, that's why our @trigger_error() was ignored.

  2. +++ b/core/modules/workspaces/tests/src/Functional/Update/WorkspacesUpdateTest.php
    @@ -55,15 +55,15 @@ public function testWorkspaceAssociationRemoval() {
         // Check that the 'workspace' field has been installed for an entity type
         // that was workspace-supported before Drupal 8.7.0.
    -    $this->assertTrue($entity_definition_update_manager->getFieldStorageDefinition('workspace', 'node'));
    +    $this->assertNotEmpty($entity_definition_update_manager->getFieldStorageDefinition('workspace', 'node'));
     
         // Check that the 'workspace' field has been installed for an entity type
         // which became workspace-supported as part of an entity schema update.
    -    $this->assertTrue($entity_definition_update_manager->getFieldStorageDefinition('workspace', 'taxonomy_term'));
    +    $this->assertNotEmpty($entity_definition_update_manager->getFieldStorageDefinition('workspace', 'taxonomy_term'));
     
         // Check that the 'workspace' field has been installed for an entity type
         // that has been added in an update function.
    -    $this->assertTrue($entity_definition_update_manager->getFieldStorageDefinition('workspace', 'path_alias'));
    +    $this->assertNotEmpty($entity_definition_update_manager->getFieldStorageDefinition('workspace', 'path_alias'));
     
    

    Thought about using assertInstanceOf but this will go away anyway in #3087644: Remove Drupal 8 updates up to and including 88**

  3. +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
    @@ -781,12 +774,6 @@ protected function installEntitySchema($entity_type_id) {
       protected function enableModules(array $modules) {
    -    $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
    -    if ($trace[1]['function'] === 'setUp') {
    -      trigger_error('KernelTestBase::enableModules() should not be called from setUp(). Use the $modules property instead.', E_USER_DEPRECATED);
    -    }
    -    unset($trace);
    -
    

    I've been wondering about this, I still don't get what will happen exactly now as we just remove the deprecation message without any actual BC code? I have a case in a project with a very complex kernel test where I need to install config before enabling another module, I guess I'll see what will happen.

  4. +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
    @@ -913,10 +900,6 @@ protected function render(array &$elements) {
        */
       protected function setSetting($name, $value) {
    -    if ($name === 'install_profile') {
    -      @trigger_error('Use \Drupal\KernelTests\KernelTestBase::setInstallProfile() to set the install profile in kernel tests. See https://www.drupal.org/node/2538996', E_USER_DEPRECATED);
    -      $this->setInstallProfile($value);
    -    }
         $settings = Settings::getInstance() ? Settings::getAll() : [];
    

    not sure if this should be removed together with the other install profile stuff instead in #2831065: Remove BC layer from \Drupal\Core\DrupalKernel::getInstallProfile() but I guess here is fine too, unless other parts of that, this isn't blocked.

mondrake’s picture

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 16: 3097892-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mondrake’s picture

Status: Needs work » Reviewed & tested by the community

Random test failure

larowlan’s picture

Do we have an issue for removing \Drupal\system\Tests\Update\UpdatePathTestBase?

longwave’s picture

@larowlan: patch in #3097453: Remove system.module BC layers covers that

larowlan’s picture

Applied this patch locally, and grepped for 'deprecated' and 'trigger_error' in classes matching *TestBase in /core/tests and only found the javascript deprecation handling in WebDriverTestBase, which is not legacy.

Adding issue credits

larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Fixed on commit

diff --git a/core/modules/file/tests/src/Functional/FileFieldTestBase.php b/core/modules/file/tests/src/Functional/FileFieldTestBase.php
index 66aad2265f..ec85536792 100644
--- a/core/modules/file/tests/src/Functional/FileFieldTestBase.php
+++ b/core/modules/file/tests/src/Functional/FileFieldTestBase.php
@@ -3,7 +3,6 @@
 namespace Drupal\Tests\file\Functional;

 use Drupal\Component\Render\FormattableMarkup;
-use Drupal\TestTools\PhpUnitCompatibility\RunnerVersion;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\file\FileInterface;

Committed 62afe77 and pushed to 9.0.x. Thanks!

  • larowlan committed 62afe77 on 9.0.x
    Issue #3097892 by mondrake, longwave, Berdir: Remove all @deprecated...

Status: Fixed » Closed (fixed)

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

mradcliffe’s picture

Issue tags: +Needs change record

So \Drupal\Tests\PhpunitCompatibilityTrait as a whole did not have a deprecation and the comments in the methods that WERE deprecated said to use the same trait but with the createMock method. Which, ironically, doesn't exist.

This caused my contrib module tests to break in 9.0.x. I think because the traits themselves didn't have @deprecated so these wouldn't have been caught by deprecated warnings.

This should have a Change record to mention the removed traits and what should be done instead.

The change record at https://www.drupal.org/node/2907725 doesn't mention this.

mradcliffe’s picture

Here's a draft change record: https://www.drupal.org/node/3112189

I linked to the change records for the @deprecated methods.

What brought me here and what was most confusing is that the PhpunitCompatibilityTrait deprecation is wrong and suggests that there is a createMock method available on that trait. It's not. It's on PHPUnit\Framework\TestCase directly. It may have existed, but I haven't dug that far into git history.

I'll update the change record related to PhpunitCompatibilityTrait::createMock once I dig into the history to find the issue that removed createMock or if it never existed at all.

quietone’s picture

Issue tags: -Needs change record

Removing tag because this has a change record.