diff --git a/src/Context/FixtureContext.php b/src/Context/FixtureContext.php index cafbb138..aec1b46a 100644 --- a/src/Context/FixtureContext.php +++ b/src/Context/FixtureContext.php @@ -23,7 +23,6 @@ use SilverStripe\Dev\FixtureFactory; use SilverStripe\Dev\YamlFixture; use SilverStripe\ORM\Connect\TempDatabase; -use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; use SilverStripe\Security\Group; @@ -694,16 +693,18 @@ public function stepGoToNamedRecord($type, $id) /** * @param $extension * @param $class + * @param $flushOnly - use ?flush=1 instead of dev/build?flush=1 * * @Given I add an extension :extension to the :class class */ - public function iAddAnExtensionToTheClass($extension, $class) + public function iAddAnExtensionToTheClass($extension, $class, bool $flushOnly = false) { // Validate the extension Assert::assertTrue( class_exists($extension ?? '') && is_subclass_of($extension, Extension::class), 'Given extension does not extend Extension' ); + /** @var Extension $extension */ // Add the extension to the CLI context /** @var Extensible $targetClass */ @@ -741,14 +742,25 @@ class_exists($extension ?? '') && is_subclass_of($extension, Extension::class), // Remember to cleanup... $this->activatedConfigFiles[] = $destPath; - // Flush website. We'll need to dev/build too if it's a DataExtension - if (is_subclass_of($extension, DataExtension::class)) { + // Flush website. We'll need to dev/build too if it's a DataObject + if (is_subclass_of($targetClass, DataObject::class) && !$flushOnly) { $this->getMainContext()->visit('/dev/build?flush'); } else { $this->getMainContext()->visit('/?flush'); } } + /** + * @param $extension + * @param $class + * + * @Given I add an extension :extension to the :class class and flush only + */ + public function iAddAnExtensionToTheClassAndFlushOnly(string $extension, string $class): void + { + $this->iAddAnExtensionToTheClass($extension, $class, true); + } + /** * Get the destination folder for config and assert the given file name doesn't exist within in. *