From e9cd597a22bfe5a35ff107d2a0c3052b2fc00d6a Mon Sep 17 00:00:00 2001 From: Niklas Forsdahl Date: Thu, 20 Jun 2024 14:58:55 +0300 Subject: [PATCH] Fixed SessionGridFieldStateManager unit test to work regardless of current gridfield state manager configuration. --- .../Forms/GridField/SessionGridFieldStateManagerTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/php/Forms/GridField/SessionGridFieldStateManagerTest.php b/tests/php/Forms/GridField/SessionGridFieldStateManagerTest.php index a296260d3..e06319358 100644 --- a/tests/php/Forms/GridField/SessionGridFieldStateManagerTest.php +++ b/tests/php/Forms/GridField/SessionGridFieldStateManagerTest.php @@ -5,15 +5,24 @@ namespace SilverStripe\Forms\Tests\GridField; use SilverStripe\Control\Controller; use SilverStripe\Control\HTTPRequest; use SilverStripe\Control\Session; +use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\GridField\GridField; +use SilverStripe\Forms\GridField\GridFieldStateManagerInterface; use SilverStripe\Forms\GridField\SessionGridFieldStateManager; use SilverStripe\Forms\Tests\GridField\GridFieldPrintButtonTest\TestObject; class SessionGridFieldStateManagerTest extends SapphireTest { + protected function setUp(): void + { + parent::setUp(); + // configure the injector to use the session grid field state manager + Injector::inst()->registerService(new SessionGridFieldStateManager(), GridFieldStateManagerInterface::class); + } + public function testStateKey() { $manager = new SessionGridFieldStateManager();