mirror of
https://github.com/shlinkio/shlink.git
synced 2024-10-23 04:35:34 +03:00
Added API tests for short URL deletion with domain
This commit is contained in:
parent
aa80c2bb82
commit
881002634a
1 changed files with 25 additions and 0 deletions
|
@ -42,4 +42,29 @@ class DeleteShortUrlActionTest extends ApiTestCase
|
||||||
$this->assertEquals($expectedDetail, $payload['detail']);
|
$this->assertEquals($expectedDetail, $payload['detail']);
|
||||||
$this->assertEquals('Cannot delete short URL', $payload['title']);
|
$this->assertEquals('Cannot delete short URL', $payload['title']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function properShortUrlIsDeletedWhenDomainIsProvided(): void
|
||||||
|
{
|
||||||
|
$fetchWithDomainBefore = $this->getJsonResponsePayload(
|
||||||
|
$this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789?domain=example.com'),
|
||||||
|
);
|
||||||
|
$fetchWithoutDomainBefore = $this->getJsonResponsePayload(
|
||||||
|
$this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789'),
|
||||||
|
);
|
||||||
|
$deleteResp = $this->callApiWithKey(self::METHOD_DELETE, '/short-urls/ghi789?domain=example.com');
|
||||||
|
$fetchWithDomainAfter = $this->getJsonResponsePayload(
|
||||||
|
$this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789?domain=example.com'),
|
||||||
|
);
|
||||||
|
$fetchWithoutDomainAfter = $this->getJsonResponsePayload(
|
||||||
|
$this->callApiWithKey(self::METHOD_GET, '/short-urls/ghi789'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals('example.com', $fetchWithDomainBefore['domain']);
|
||||||
|
$this->assertEquals(null, $fetchWithoutDomainBefore['domain']);
|
||||||
|
$this->assertEquals(self::STATUS_NO_CONTENT, $deleteResp->getStatusCode());
|
||||||
|
// Falls back to the one without domain, since the other one has been deleted
|
||||||
|
$this->assertEquals(null, $fetchWithDomainAfter['domain']);
|
||||||
|
$this->assertEquals(null, $fetchWithoutDomainAfter['domain']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue