From a117582e057d5f790f76e0d41d6428849bbe5347 Mon Sep 17 00:00:00 2001 From: venyii Date: Tue, 17 Oct 2017 17:19:17 +0200 Subject: [PATCH] Fix nullable ClientInterface return type in admin api The underlying `findOneBy` may return null, the docblock seems to be wrong. --- src/Sylius/Bundle/AdminApiBundle/Model/ClientManager.php | 2 +- .../Bundle/AdminApiBundle/spec/Model/ClientManagerSpec.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Sylius/Bundle/AdminApiBundle/Model/ClientManager.php b/src/Sylius/Bundle/AdminApiBundle/Model/ClientManager.php index f3edbe15520..6c23076c22b 100644 --- a/src/Sylius/Bundle/AdminApiBundle/Model/ClientManager.php +++ b/src/Sylius/Bundle/AdminApiBundle/Model/ClientManager.php @@ -24,7 +24,7 @@ class ClientManager extends BaseClientManager /** * {@inheritdoc} */ - public function findClientByPublicId($publicId): ClientInterface + public function findClientByPublicId($publicId): ?ClientInterface { return $this->findClientBy(['randomId' => $publicId]); } diff --git a/src/Sylius/Bundle/AdminApiBundle/spec/Model/ClientManagerSpec.php b/src/Sylius/Bundle/AdminApiBundle/spec/Model/ClientManagerSpec.php index bb1945c6266..6b09c4928e2 100644 --- a/src/Sylius/Bundle/AdminApiBundle/spec/Model/ClientManagerSpec.php +++ b/src/Sylius/Bundle/AdminApiBundle/spec/Model/ClientManagerSpec.php @@ -44,4 +44,11 @@ function it_finds_client_by_public_id(ClientInterface $client, $repository): voi $this->findClientByPublicId('random_string')->shouldReturn($client); } + + function it_returns_null_if_client_does_not_exist($repository): void + { + $repository->findOneBy(['randomId' => 'random_string'])->willReturn(null); + + $this->findClientByPublicId('random_string')->shouldReturn(null); + } }