emptyResponseIsReturnedIfProperlyDeleted()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ShlinkioTest\Shlink\Rest\Action\ShortUrl;
6
7
use Laminas\Diactoros\ServerRequest;
8
use PHPUnit\Framework\TestCase;
9
use Prophecy\Argument;
10
use Prophecy\PhpUnit\ProphecyTrait;
11
use Prophecy\Prophecy\ObjectProphecy;
12
use Shlinkio\Shlink\Core\Service\ShortUrl\DeleteShortUrlServiceInterface;
13
use Shlinkio\Shlink\Rest\Action\ShortUrl\DeleteShortUrlAction;
14
15
class DeleteShortUrlActionTest extends TestCase
16
{
17
    use ProphecyTrait;
18
19
    private DeleteShortUrlAction $action;
20
    private ObjectProphecy $service;
21
22
    public function setUp(): void
23
    {
24
        $this->service = $this->prophesize(DeleteShortUrlServiceInterface::class);
25
        $this->action = new DeleteShortUrlAction($this->service->reveal());
26
    }
27
28
    /** @test */
29
    public function emptyResponseIsReturnedIfProperlyDeleted(): void
30
    {
31
        $deleteByShortCode = $this->service->deleteByShortCode(Argument::any())->will(function (): void {
32
        });
33
34
        $resp = $this->action->handle(new ServerRequest());
35
36
        self::assertEquals(204, $resp->getStatusCode());
37
        $deleteByShortCode->shouldHaveBeenCalledOnce();
38
    }
39
}
40