bug: #3631465: Remove the code deprecated in Mapillary Module

Removes the compatibility layer deprecated in 1.0.0-alpha6 and makes the tests run without PHPUnit 12 notices.

Removed

  • The old class files in mapillary_field/src/: Service/MapillaryApiClient.php, Service/MapillaryImageImporter.php, Event/MapillaryApiCallEvent.php, Exception/MissingAccessTokenException.php.
  • The four class_alias() calls at the bottom of the new class files.
  • The service aliases mapillary_field.api_client and mapillary_field.image_importer.
  • The old constructor signatures of MapillaryApiClient, MapillaryImageImporter, MapillaryMapFeatureImporter and MapillaryDetectionImporter: no union type, no $legacyLogger, no InvalidArgumentException for the old argument order.
  • MapillaryImageImporter::importSequence(). Callers use importSequenceMetadata($id)->entity and queue the images with mapillary_field.sequence_cascade_queuer. Its note on the sequence_id natural key moved to the importSequenceMetadata() docblock.
  • MapillaryThumbnailRefresher::isServiceWideFailure(); MapillaryApiException::isServiceWide() replaces it and is tested in MapillaryApiExceptionTest.
  • MapillaryLeafletWidgetBase::GRAPH_BASE_URL; use MapillaryBrowserSettings::GRAPH_BASE_URL.
  • The tests of the compatibility layer: LegacyApiClassNamesTest, LegacyApiClientServiceTest, MapillaryThumbnailRefresherFailureTest, and the legacy methods in MapillaryApiClientTest, the kernel ImageImporterTest and the unit MapillaryImageImporterTest. Besides the methods listed in the issue, MapillaryApiClientTest::testLegacyConstructorWithoutDispatcher() is removed too: it tested the InvalidArgumentException of the old signature.

CHANGELOG.md has a "Removed" section under [Unreleased], and AGENTS.md no longer describes the compatibility layer.

Test doubles

  • A double that only returns values is created with createStub().
  • Where a mock checked its arguments with ->with() but had no expects(), it stays a mock and gets the call count of the real flow (once(), exactly(n)). with() on a stub has no effect and is deprecated in PHPUnit 12.
  • Doubles shared from setUp() are stubs by default; a test that checks a call asks for a mock through a small helper (for example mockStorage(), mockApiClient()), and the subject is built after the doubles (importer(), worker(), queuer()).
  • #[AllowMockObjectsWithoutExpectations] and expects($this->any()) are not used.
  • No existing assertion or expects() was removed.

Upgrade

No update hook. A site on 1.0.0-alpha6 already builds the services from the new definitions; the constructor arguments in the service files did not change. Sites on 1.0.0-alpha5 or older update to 1.0.0-alpha6 and run drush updatedb first, as the changelog says.

Testing

Unit and kernel tests, run locally:

  • Drupal 11 with PostgreSQL, PHPUnit 11.5: all pass.
  • Drupal 12.0.0-beta1, PHP 8.5, PHPUnit 12.5.39, SQLite: all pass, with no "No expectations were configured" notices (289 before) and no "Using with*() on a test stub" deprecations. The exception is MapillaryFieldCommandsTest, which errors there because Drush cannot be installed on Drupal 12 yet (Class "Drush\Commands\DrushCommands" not found), so its notices could not be checked; it passes on Drupal 11.

phpcs (Drupal, DrupalPractice) and PHPStan level 6 report nothing new on the changed files.

Not run locally: functional and FunctionalJavascript tests, and the update rehearsal from 1.0.0-alpha6.

Closes #3631465

Merge request reports

Loading
Loading