diff --git a/src/AuraSessionModule.php b/src/AuraSessionModule.php index 8db95d3..bd40b4d 100644 --- a/src/AuraSessionModule.php +++ b/src/AuraSessionModule.php @@ -28,10 +28,10 @@ protected function configure() { $this->bind(Session::class)->toConstructor(Session::class, [ 'cookies' => Cookie::class, - 'delete_cookie' => DeleteCookie::class + 'delete_cookie' => DeleteCookie::class, ]); $this->bind()->annotatedWith(Cookie::class)->toProvider(CookieProvider::class); - $this->bind()->annotatedWith(DeleteCookie::class)->toInstance(null); + $this->bind()->annotatedWith(DeleteCookie::class)->toInstance([new DeleteCookieInvoker(), '__invoke']); $this->bind(SegmentFactory::class); $this->bind(CsrfTokenFactory::class); $this->bind(RandvalInterface::class)->to(Randval::class); diff --git a/src/DeleteCookieInvoker.php b/src/DeleteCookieInvoker.php new file mode 100644 index 0000000..2bf2658 --- /dev/null +++ b/src/DeleteCookieInvoker.php @@ -0,0 +1,31 @@ +getInstance(Session::class); $this->assertInstanceOf(Session::class, $session); } + + public function testSerialize(): void + { + $injector = new Injector(new AuraSessionModule()); + $session = $injector->getInstance(Session::class); + $serialized = serialize($session); + $this->assertIsString($serialized); + } + + public function testDeserialize(): void + { + $injector = new Injector(new AuraSessionModule()); + $session = $injector->getInstance(Session::class); + $serialized = serialize($session); + $deserialized = unserialize($serialized); + $this->assertInstanceOf(Session::class, $deserialized); + } }