diff --git a/MIGRATION.md b/MIGRATION.md index 4d64cb08b..0cc08a3a9 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1919,7 +1919,7 @@ A tag that was only meant for some of the scenarios in a feature moves down onto Mink owns the word "driver" across the Behat ecosystem, and this package used it for a second thing: the Drupal, Drush and Blackbox backends a step resolves a capability from. So `$this->getDriver('drupal')` and `$this->getSession()->getDriver()` returned 2 unrelated objects, and only a naming rule told them apart. The backends now carry their own name, and "driver" in this package only ever means Mink's browser driver. -Apart from 1 removed interface, it's a rename: behaviour stays the same, and no step text changes. Configuration and feature files fail until they're renamed, and PHP that calls a renamed class or method fails on the missing name, so nothing keeps running against the old names by accident. +Apart from 1 removed interface, it's a rename: behaviour stays the same, and no step text changes. Configuration and feature files fail until they're renamed, and PHP that calls a renamed class or method fails on the missing name. The service container is the exception: a parameter, service tag or service id under its old name can go unread without an error, so [Service ids and parameters](#service-ids-and-parameters) lists what to check. ### Configuration and tags @@ -2075,6 +2075,8 @@ A parameter named `$driver` that held a backend is now `$backend`. That only mat The parameters follow their service: `behat_steps.driver_registry.class` becomes `behat_steps.backend_registry.class`, `behat_steps.driver.drush.binary` becomes `behat_steps.backend.drush.binary`, and so on for every `.class`, `drupal_root`, `alias`, `binary` and `root` parameter. Unlike the configuration key, a parameter under its old name isn't rejected - it's just never read again - so a suite that swaps an implementation through one should check it renamed it. +An old service id is only loud where something requires it. An `@behat_steps.driver_registry` argument or a `getDefinition()` call fails the container build on the missing service, though Symfony's message doesn't mention the rename. A `hasDefinition()` check or a service defined under an old id is as quiet as a parameter. + A backend of your own registers by tagging its service `behat_steps.backend`, with the name it answers to as the alias: ```yaml @@ -2087,6 +2089,10 @@ tags: - { name: behat_steps.backend, alias: acme-jsonapi } ``` +A service still tagged `behat_steps.driver` isn't registered at all. When the `backends` list names it, the container build fails with `The "backends" list under "behat_steps" names the backend "acme-jsonapi", which is not registered.` Without a `backends` list it's left out of the scenario's order, so each step resolves the first remaining backend that provides its capability, or fails with `No backend provides "..."` when none does. + +`grep -rnE 'behat_steps\.(listener\.)?driver' ` lists every container name that needs the rename: parameters, service ids and tags. + ### Messages A failure that names the concept now says "backend", so a test that asserts one of these messages needs the new text: diff --git a/docs.php b/docs.php index fb20e03c7..8aa5139b8 100644 --- a/docs.php +++ b/docs.php @@ -37,8 +37,8 @@ use DrevOps\BehatSteps\Behat\Prerequisite\PrerequisiteReader; use DrevOps\BehatSteps\Behat\ServiceContainer\BehatStepsExtension; use Symfony\Component\Config\Definition\ArrayNode; -use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\BooleanNode; +use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\IntegerNode; use Symfony\Component\Config\Definition\NodeInterface; use Symfony\Component\Config\Definition\PrototypedArrayNode; diff --git a/docs/usage.md b/docs/usage.md index 4b7492c53..ddd84deda 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -84,8 +84,8 @@ A suite that writes its own Drupal steps composes the helper for the concern it + diff --git a/src/Behat/Generator/ClassGenerator.php b/src/Behat/Generator/ClassGenerator.php index 1f90789d4..d9b8a153b 100644 --- a/src/Behat/Generator/ClassGenerator.php +++ b/src/Behat/Generator/ClassGenerator.php @@ -25,10 +25,10 @@ class ClassGenerator implements UpstreamClassGenerator { protected static string $template = <<<'PHP' process = Process::fromShellCommandline($cmd); - // Prepare the process parameters. The 3.x DrupalDriver bootstraps Drupal - // in-process before any step runs, which on @api scenarios with module - // install/uninstall easily eats >20s in this environment. Bump the - // ceiling so behat-cli driven tests have headroom for the slow path. + // Prepare the process parameters. The Drupal backend bootstraps Drupal + // in-process, which on @api scenarios with module install/uninstall easily + // eats >20s in this environment. Bump the ceiling so behat-cli driven + // tests have headroom for the slow path. $this->process->setTimeout(60); $this->process->setEnv($this->env); $this->process->setWorkingDirectory($this->workingDir); diff --git a/tests/behat/bootstrap/BehatCliTrait.php b/tests/behat/bootstrap/BehatCliTrait.php index df0460d23..6f136c02d 100644 --- a/tests/behat/bootstrap/BehatCliTrait.php +++ b/tests/behat/bootstrap/BehatCliTrait.php @@ -150,9 +150,9 @@ public function behatCliWriteFeatureContextFile(array $traits = []): string { use Behat\Hook\AfterScenario; use Behat\Step\Given; +use DrevOps\BehatSteps\Backend\Capability\CoreCapabilityInterface; use DrevOps\BehatSteps\Behat\Context\UserAwareInterface; use DrevOps\BehatSteps\Behat\Context\WebRawContext; -use DrevOps\BehatSteps\Backend\Capability\CoreCapabilityInterface; use DrevOps\BehatSteps\Helper\Drupal\AuthTrait; use DrevOps\BehatSteps\Helper\Drupal\StaticCacheTrait; {{USE_DECLARATION}} diff --git a/tests/phpunit/src/Kernel/Backend/Core/CoreBlockMethodsKernelTest.php b/tests/phpunit/src/Kernel/Backend/Core/CoreBlockMethodsKernelTest.php index 674df893d..2f12449ce 100644 --- a/tests/phpunit/src/Kernel/Backend/Core/CoreBlockMethodsKernelTest.php +++ b/tests/phpunit/src/Kernel/Backend/Core/CoreBlockMethodsKernelTest.php @@ -6,10 +6,10 @@ use DrevOps\BehatSteps\Backend\Core\Core; use DrevOps\BehatSteps\Backend\Entity\EntityStub; -use Drupal\KernelTests\KernelTestBase; use Drupal\block\Entity\Block; use Drupal\block_content\Entity\BlockContent; use Drupal\block_content\Entity\BlockContentType; +use Drupal\KernelTests\KernelTestBase; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; diff --git a/tests/phpunit/src/Kernel/Backend/Core/CoreCacheMethodsKernelTest.php b/tests/phpunit/src/Kernel/Backend/Core/CoreCacheMethodsKernelTest.php index 7800b3a9e..fcd02939b 100644 --- a/tests/phpunit/src/Kernel/Backend/Core/CoreCacheMethodsKernelTest.php +++ b/tests/phpunit/src/Kernel/Backend/Core/CoreCacheMethodsKernelTest.php @@ -46,37 +46,37 @@ protected function setUp(): void { */ public function testCacheClearDispatches(): void { // Populate a cache entry so the clear has something to flush. - \Drupal::cache()->set('drupal_driver_test:sentinel', 'value'); - $this->assertNotFalse(\Drupal::cache()->get('drupal_driver_test:sentinel')); + \Drupal::cache()->set('drupal_backend_test:sentinel', 'value'); + $this->assertNotFalse(\Drupal::cache()->get('drupal_backend_test:sentinel')); $this->core->cacheClear(); - $this->assertFalse(\Drupal::cache()->get('drupal_driver_test:sentinel')); + $this->assertFalse(\Drupal::cache()->get('drupal_backend_test:sentinel')); } /** * Tests that 'cacheClearStatic()' resets Drupal's static caches. */ public function testCacheClearStaticResetsStatics(): void { - $counter = &drupal_static('drupal_driver_test_counter'); + $counter = &drupal_static('drupal_backend_test_counter'); $counter = 7; - $this->assertSame(7, drupal_static('drupal_driver_test_counter')); + $this->assertSame(7, drupal_static('drupal_backend_test_counter')); $this->core->cacheClearStatic(); - $this->assertNull(drupal_static('drupal_driver_test_counter')); + $this->assertNull(drupal_static('drupal_backend_test_counter')); } /** * Tests that 'cacheClearStatic()' empties the memory cache bin. */ public function testCacheClearStaticEmptiesTheMemoryBin(): void { - \Drupal::cache('memory')->set('drupal_driver_test:memory', 'value'); - $this->assertNotFalse(\Drupal::cache('memory')->get('drupal_driver_test:memory')); + \Drupal::cache('memory')->set('drupal_backend_test:memory', 'value'); + $this->assertNotFalse(\Drupal::cache('memory')->get('drupal_backend_test:memory')); $this->core->cacheClearStatic(); - $this->assertFalse(\Drupal::cache('memory')->get('drupal_driver_test:memory')); + $this->assertFalse(\Drupal::cache('memory')->get('drupal_backend_test:memory')); } /** diff --git a/tests/phpunit/src/Kernel/Backend/Core/CoreEntityCreateCommerceKernelTest.php b/tests/phpunit/src/Kernel/Backend/Core/CoreEntityCreateCommerceKernelTest.php index 229dfdbeb..aca5bdd55 100644 --- a/tests/phpunit/src/Kernel/Backend/Core/CoreEntityCreateCommerceKernelTest.php +++ b/tests/phpunit/src/Kernel/Backend/Core/CoreEntityCreateCommerceKernelTest.php @@ -6,9 +6,9 @@ use DrevOps\BehatSteps\Backend\Core\Core; use DrevOps\BehatSteps\Backend\Entity\EntityStub; -use Drupal\KernelTests\KernelTestBase; use Drupal\commerce_product\Entity\Product; use Drupal\commerce_store\Entity\Store; +use Drupal\KernelTests\KernelTestBase; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; diff --git a/tests/phpunit/src/Kernel/Backend/Core/CoreEntityCreateModerationStateKernelTest.php b/tests/phpunit/src/Kernel/Backend/Core/CoreEntityCreateModerationStateKernelTest.php index 8355127a4..434c1529c 100644 --- a/tests/phpunit/src/Kernel/Backend/Core/CoreEntityCreateModerationStateKernelTest.php +++ b/tests/phpunit/src/Kernel/Backend/Core/CoreEntityCreateModerationStateKernelTest.php @@ -6,9 +6,9 @@ use DrevOps\BehatSteps\Backend\Core\Core; use DrevOps\BehatSteps\Backend\Entity\EntityStub; -use Drupal\KernelTests\KernelTestBase; use Drupal\content_moderation\Entity\ContentModerationState; use Drupal\content_moderation\Plugin\WorkflowType\ContentModeration; +use Drupal\KernelTests\KernelTestBase; use Drupal\node\Entity\Node; use Drupal\node\Entity\NodeType; use Drupal\workflows\Entity\Workflow; diff --git a/tests/phpunit/src/Kernel/Backend/Core/CoreEntityMethodsKernelTest.php b/tests/phpunit/src/Kernel/Backend/Core/CoreEntityMethodsKernelTest.php index cd055a494..1150b7f0c 100644 --- a/tests/phpunit/src/Kernel/Backend/Core/CoreEntityMethodsKernelTest.php +++ b/tests/phpunit/src/Kernel/Backend/Core/CoreEntityMethodsKernelTest.php @@ -7,8 +7,8 @@ use DrevOps\BehatSteps\Backend\Core\Core; use DrevOps\BehatSteps\Backend\Entity\EntityStub; use Drupal\Core\Entity\EntityInterface; -use Drupal\KernelTests\KernelTestBase; use Drupal\entity_test\EntityTestHelper; +use Drupal\KernelTests\KernelTestBase; use Drupal\user\Entity\Role; use Drupal\user\Entity\User; use PHPUnit\Framework\Attributes\CoversClass; diff --git a/tests/phpunit/src/Kernel/Backend/Core/Field/FieldHandlerKernelTestBase.php b/tests/phpunit/src/Kernel/Backend/Core/Field/FieldHandlerKernelTestBase.php index 5e2506e8a..917ee2906 100644 --- a/tests/phpunit/src/Kernel/Backend/Core/Field/FieldHandlerKernelTestBase.php +++ b/tests/phpunit/src/Kernel/Backend/Core/Field/FieldHandlerKernelTestBase.php @@ -7,10 +7,10 @@ use DrevOps\BehatSteps\Backend\Core\Core; use DrevOps\BehatSteps\Backend\Entity\EntityStub; use Drupal\Core\Entity\ContentEntityInterface; -use Drupal\KernelTests\KernelTestBase; use Drupal\entity_test\EntityTestHelper; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; +use Drupal\KernelTests\KernelTestBase; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; /** diff --git a/tests/phpunit/src/Kernel/Helper/Drupal/EntityLifecycleTraitVocabularyKernelTest.php b/tests/phpunit/src/Kernel/Helper/Drupal/EntityLifecycleTraitVocabularyKernelTest.php index 3052a8932..5bb79d5be 100644 --- a/tests/phpunit/src/Kernel/Helper/Drupal/EntityLifecycleTraitVocabularyKernelTest.php +++ b/tests/phpunit/src/Kernel/Helper/Drupal/EntityLifecycleTraitVocabularyKernelTest.php @@ -9,15 +9,15 @@ use Behat\Testwork\Environment\EnvironmentManager; use Behat\Testwork\Hook\HookDispatcher; use Behat\Testwork\Hook\HookRepository; -use DrevOps\BehatSteps\Helper\Drupal\EntityLifecycleTrait; -use DrevOps\BehatSteps\Behat\Manager\BackendRegistry; -use DrevOps\BehatSteps\Behat\Manager\BackendRegistryInterface; +use DrevOps\BehatSteps\Backend\BackendInterface; use DrevOps\BehatSteps\Backend\Capability\ContentCapabilityInterface; use DrevOps\BehatSteps\Backend\Core\CoreInterface; use DrevOps\BehatSteps\Backend\Core\Field\FieldClassifierInterface; -use DrevOps\BehatSteps\Backend\BackendInterface; use DrevOps\BehatSteps\Backend\DrupalBackendInterface; use DrevOps\BehatSteps\Backend\Entity\EntityStub; +use DrevOps\BehatSteps\Behat\Manager\BackendRegistry; +use DrevOps\BehatSteps\Behat\Manager\BackendRegistryInterface; +use DrevOps\BehatSteps\Helper\Drupal\EntityLifecycleTrait; use DrevOps\BehatSteps\Tests\Unit\Behat\Fixtures\TestableRawContext; use Drupal\KernelTests\KernelTestBase; use Drupal\taxonomy\Entity\Vocabulary; diff --git a/tests/phpunit/src/Unit/Backend/CoreLookupTest.php b/tests/phpunit/src/Unit/Backend/CoreLookupTest.php index e8068791c..cef4a6ae5 100644 --- a/tests/phpunit/src/Unit/Backend/CoreLookupTest.php +++ b/tests/phpunit/src/Unit/Backend/CoreLookupTest.php @@ -4,8 +4,8 @@ namespace DrevOps\BehatSteps\Tests\Unit\Backend; -use DrevOps\BehatSteps\Backend\Core99\Core as Core99Core; use DrevOps\BehatSteps\Backend\Core\Core; +use DrevOps\BehatSteps\Backend\Core99\Core as Core99Core; use DrevOps\BehatSteps\Backend\DrupalBackend; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; diff --git a/tests/phpunit/src/Unit/Backend/DrushBackendResultTest.php b/tests/phpunit/src/Unit/Backend/DrushBackendResultTest.php index eebdbb940..9d46fa105 100644 --- a/tests/phpunit/src/Unit/Backend/DrushBackendResultTest.php +++ b/tests/phpunit/src/Unit/Backend/DrushBackendResultTest.php @@ -4,8 +4,8 @@ namespace DrevOps\BehatSteps\Tests\Unit\Backend; -use DrevOps\BehatSteps\Backend\DrushBackend; use DrevOps\BehatSteps\Backend\Drush\DrushResult; +use DrevOps\BehatSteps\Backend\DrushBackend; use DrevOps\BehatSteps\Tests\Unit\Backend\Fixtures\ProcessStubDrushBackend; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; diff --git a/tests/phpunit/src/Unit/Behat/Generator/ClassGeneratorTest.php b/tests/phpunit/src/Unit/Behat/Generator/ClassGeneratorTest.php index dc1951b8d..d9273342a 100644 --- a/tests/phpunit/src/Unit/Behat/Generator/ClassGeneratorTest.php +++ b/tests/phpunit/src/Unit/Behat/Generator/ClassGeneratorTest.php @@ -51,10 +51,10 @@ public static function dataProviderGenerateClass(): \Iterator { namespace App\Tests\Behat; -use DrevOps\BehatSteps\Behat\Context\WebRawContext; +use Behat\Behat\Tester\Exception\PendingException; use Behat\Gherkin\Node\PyStringNode; use Behat\Gherkin\Node\TableNode; -use Behat\Behat\Tester\Exception\PendingException; +use DrevOps\BehatSteps\Behat\Context\WebRawContext; /** * Defines application features from the specific context. @@ -82,10 +82,10 @@ public function __construct(array $config = []) { $rootless = <<<'PHP'