From 863803b61403884d5382d016f2a9f2cea2476fad Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 31 Jul 2018 19:59:41 +0200 Subject: [PATCH] Fixed tests failing with new typehints --- module/CLI/test/Command/Api/GenerateKeyCommandTest.php | 9 ++++++--- module/CLI/test/Command/Tag/CreateTagCommandTest.php | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/module/CLI/test/Command/Api/GenerateKeyCommandTest.php b/module/CLI/test/Command/Api/GenerateKeyCommandTest.php index 7c9482f7..88a44ab8 100644 --- a/module/CLI/test/Command/Api/GenerateKeyCommandTest.php +++ b/module/CLI/test/Command/Api/GenerateKeyCommandTest.php @@ -7,6 +7,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; use Shlinkio\Shlink\CLI\Command\Api\GenerateKeyCommand; +use Shlinkio\Shlink\Rest\Entity\ApiKey; use Shlinkio\Shlink\Rest\Service\ApiKeyService; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; @@ -37,7 +38,8 @@ class GenerateKeyCommandTest extends TestCase */ public function noExpirationDateIsDefinedIfNotProvided() { - $this->apiKeyService->create(null)->shouldBeCalledTimes(1); + $this->apiKeyService->create(null)->shouldBeCalledTimes(1) + ->willReturn(new ApiKey()); $this->commandTester->execute([ 'command' => 'api-key:generate', ]); @@ -46,9 +48,10 @@ class GenerateKeyCommandTest extends TestCase /** * @test */ - public function expirationDateIsDefinedIfWhenProvided() + public function expirationDateIsDefinedIfProvided() { - $this->apiKeyService->create(Argument::type(\DateTime::class))->shouldBeCalledTimes(1); + $this->apiKeyService->create(Argument::type(\DateTime::class))->shouldBeCalledTimes(1) + ->willReturn(new ApiKey()); $this->commandTester->execute([ 'command' => 'api-key:generate', '--expirationDate' => '2016-01-01', diff --git a/module/CLI/test/Command/Tag/CreateTagCommandTest.php b/module/CLI/test/Command/Tag/CreateTagCommandTest.php index a81a2383..39b6f59f 100644 --- a/module/CLI/test/Command/Tag/CreateTagCommandTest.php +++ b/module/CLI/test/Command/Tag/CreateTagCommandTest.php @@ -3,6 +3,7 @@ declare(strict_types=1); namespace ShlinkioTest\Shlink\CLI\Command\Tag; +use Doctrine\Common\Collections\ArrayCollection; use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\MethodProphecy; use Prophecy\Prophecy\ObjectProphecy; @@ -52,7 +53,7 @@ class CreateTagCommandTest extends TestCase { $tagNames = ['foo', 'bar']; /** @var MethodProphecy $createTags */ - $createTags = $this->tagService->createTags($tagNames)->willReturn([]); + $createTags = $this->tagService->createTags($tagNames)->willReturn(new ArrayCollection()); $this->commandTester->execute([ '--name' => $tagNames,