Problem/Motivation

SimpleTest was deprecated in Drupal 8 and moved to contrib in Drupal 9. There has been no activity in the contrib issue queue and it seems everyone has migrated to PHPUnit, which was the desired outcome.

According to @catch in #3254725-2: [meta] Remove SimpleTest support:

We need an issue to remove the core/modules/simpletest folder. We should have removed it in #3261486: Remove core updates added prior to 9.3.0 and adjust test coverage.

Well, here it is.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3293288

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Spokje created an issue. See original summary.

Spokje’s picture

longwave’s picture

There is a reference in a migrate test for some reason:

core/modules/file/tests/src/Kernel/Migrate/d6/FileMigrationTestTrait.php
32:      $source['site_path'] = 'core/modules/simpletest';

This should probably be updated, but not sure what to!

Spokje’s picture

Weirdly, all kernel tests pass without removing it. I'll have a closer look at it, but I'm _very_ much not at home in the Migration World.

We might have to call in the Cavalry of Migration Subsystem Maintainers.

alexpott’s picture

@longwave nice catch.

I'm pretty sure that this is due to the fact that simpletest used to have all the of the test files in it. Yep that's why.

The files all moved to 'core/test/fixtures/files' so the current setting should be 'core/test/fixtures' - and we can change this to that. FWIW this is not necessary because this is only used here:

    $site_path = $this->configuration['site_path'] ?? 'sites/default';
    $this->filePath = $this->variableGet('file_directory_path', $site_path . '/files') . '/';

And the file_directory_path is set to 'core/test/fixtures' but there is no harm in changing it in the test to something that makes sense.

alexpott’s picture

longwave’s picture

Status: Active » Needs work

NW for #6.

alexpott’s picture

Note that #3080163: Decouple TestFileCreationTrait::getTestFiles() from simpletest module did update the drupal6 db fixture and change the file directory path... which is why everything works. So if something in contrib was depending on the trait setting it correctly it has been long since broken... so maybe it is better to remove it. The other option would be to update the Drupal6 db in one of that test and set the D6 variable to an empty string so we can have test coverage of the fallback...

We'd need to do something like

    // Remove the file_directory_path.
    Database::getConnection('default', 'migrate')
      ->delete('variable')
      ->condition('name', 'file_directory_path')
      ->execute();

in one of the tests that use the trait.

Spokje’s picture

Status: Needs work » Active

FWIW: I always get a blood red mist before my eyes when I see the word remove, so I kicked of a test on 9.5.x and 10.0.x as-is, with a straight up removal of \Drupal\Tests\file\Kernel\Migrate\d6\FileMigrationTestTrait::prepareMigration here #3292008-16: [Ignore] In space (and/or this issue), no one can hear patches scream III just to see what happens.

That was a bit much, now trying only removing $source['site_path'] = 'core/modules/simpletest'; here #3292008-17: [Ignore] In space (and/or this issue), no one can hear patches scream III

Spokje’s picture

Status: Active » Needs work

Unwanted Status change.

alexpott’s picture

@Spokje removing $source['site_path'] = 'core/modules/simpletest'; will work. But as per #9 this means we are lacking test coverage.

What we need to do is set it to core/test/fixtures and then in \Drupal\Tests\file\Kernel\Migrate\d6\MigrateFileTest::setUp add

    // Remove the file_directory_path to test site_path setting.
    Database::getConnection('default', 'migrate')
      ->delete('variable')
      ->condition('name', 'file_directory_path')
      ->execute();

after the call to the parent set up.

And then later in the test you will need to change the update of file_directory_path to an insert...ie...

    Database::getConnection('default', 'migrate')
      ->insert('variable')
      ->fields(['name', 'value'])
      ->values(['name' => 'file_directory_path', 'value' => serialize('files/test')])
      ->execute();
Spokje’s picture

Assigned: Spokje » Unassigned

Fine by me. Un-assigning myself since I've got way too many issues ATM.

alexpott’s picture

Status: Needs work » Needs review

I've fixed #12. What's really interesting is that \Drupal\Tests\file\Kernel\Migrate\d6\MigrateFileTest::testFiles already has this comment:

    // Test that we can re-import and also test with file_directory_path set.
    \Drupal::database()
      ->truncate($map_table)
      ->execute();

So it seems there was an intention to test without a file_directory_path variable set - so we are now reinstating that test coverage.

quietone’s picture

Status: Needs review » Reviewed & tested by the community

Took a moment to remember that the d6 source plugin uses site_path, but got there in the end. To be sure I was reading the test correctly (still recovery from flu) I walked through the test with the debugger and found it is working as expected and no test coverage has been lost.

Off we go!

  • catch committed 952cb0b on 10.0.x
    Issue #3293288 by Spokje, alexpott, longwave, quietone: Remove the /core...
  • catch committed 0586c53 on 10.1.x
    Issue #3293288 by Spokje, alexpott, longwave, quietone: Remove the /core...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.1.x and cherry-picked to 10.0.x, thanks!

Status: Fixed » Closed (fixed)

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