From d2b227c89e8bb61d36ec915bca5e55eb3520795c Mon Sep 17 00:00:00 2001 From: Marcel Strahl Date: Thu, 17 Sep 2020 15:32:23 +0200 Subject: [PATCH] remove unused cache dir in response factory fix config namespace for using class constants --- src/ResponseFactory.php | 7 +------ tests/ResponseFactoryTest.php | 14 +++++++------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/ResponseFactory.php b/src/ResponseFactory.php index cbf7fa2..89cbaeb 100644 --- a/src/ResponseFactory.php +++ b/src/ResponseFactory.php @@ -4,6 +4,7 @@ namespace Dropelikeit\LaravelJmsSerializer; use ArrayIterator; +use Dropelikeit\LaravelJmsSerializer\Config\Config; use Dropelikeit\LaravelJmsSerializer\Config\ConfigInterface; use Dropelikeit\LaravelJmsSerializer\Exception\SerializeType; use JMS\Serializer\SerializationContext; @@ -40,17 +41,11 @@ final class ResponseFactory */ private $serializeType; - /** - * @var string - */ - private $cacheDir; - public function __construct(SerializerInterface $serializer, ConfigInterface $config) { $this->config = $config; $this->serializer = $serializer; $this->serializeType = $config->getSerializeType(); - $this->cacheDir = $config->getCacheDir(); } public function withStatusCode(int $code): void diff --git a/tests/ResponseFactoryTest.php b/tests/ResponseFactoryTest.php index 770c768..2de57cf 100644 --- a/tests/ResponseFactoryTest.php +++ b/tests/ResponseFactoryTest.php @@ -40,7 +40,7 @@ public function setUp(): void public function canCreateResponse(): void { $this->config - ->expects(self::exactly(2)) + ->expects(self::once()) ->method('getCacheDir') ->willReturn(__DIR__); @@ -68,7 +68,7 @@ public function canCreateResponse(): void public function canCreateFromArrayIterator(): void { $this->config - ->expects(self::exactly(2)) + ->expects(self::once()) ->method('getCacheDir') ->willReturn(__DIR__); @@ -96,7 +96,7 @@ public function canCreateFromArrayIterator(): void public function canCreateResponseFromArray(): void { $this->config - ->expects(self::exactly(2)) + ->expects(self::once()) ->method('getCacheDir') ->willReturn(__DIR__); @@ -127,7 +127,7 @@ public function canCreateResponseFromArray(): void public function canChangeStatusCode(): void { $this->config - ->expects(self::exactly(2)) + ->expects(self::once()) ->method('getCacheDir') ->willReturn(__DIR__); @@ -157,7 +157,7 @@ public function canChangeStatusCode(): void public function canUseGivenContext(): void { $this->config - ->expects(self::exactly(2)) + ->expects(self::once()) ->method('getCacheDir') ->willReturn(__DIR__); @@ -185,7 +185,7 @@ public function canUseGivenContext(): void public function canWithSerializeType(): void { $this->config - ->expects(self::exactly(3)) + ->expects(self::once()) ->method('getCacheDir') ->willReturn(__DIR__); @@ -224,7 +224,7 @@ public function canNotCreateWithUnknownSerializeType(): void $this->expectException(SerializeType::class); $this->config - ->expects(self::exactly(2)) + ->expects(self::once()) ->method('getCacheDir') ->willReturn(__DIR__);