mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Increased MSI to 64%
This commit is contained in:
35
module/Common/test/Exception/WrongIpExceptionTest.php
Normal file
35
module/Common/test/Exception/WrongIpExceptionTest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Common\Exception;
|
||||
|
||||
use Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shlinkio\Shlink\Common\Exception\WrongIpException;
|
||||
|
||||
class WrongIpExceptionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function fromIpAddressProperlyCreatesExceptionWithoutPrev()
|
||||
{
|
||||
$e = WrongIpException::fromIpAddress('1.2.3.4');
|
||||
|
||||
$this->assertEquals('Provided IP "1.2.3.4" is invalid', $e->getMessage());
|
||||
$this->assertEquals(0, $e->getCode());
|
||||
$this->assertNull($e->getPrevious());
|
||||
}
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function fromIpAddressProperlyCreatesExceptionWithPrev()
|
||||
{
|
||||
$prev = new Exception('Previous error');
|
||||
$e = WrongIpException::fromIpAddress('1.2.3.4', $prev);
|
||||
|
||||
$this->assertEquals('Provided IP "1.2.3.4" is invalid', $e->getMessage());
|
||||
$this->assertEquals(0, $e->getCode());
|
||||
$this->assertSame($prev, $e->getPrevious());
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ class DbUpdaterTest extends TestCase
|
||||
$request = $this->httpClient->request(Argument::cetera())->willThrow(ClientException::class);
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->expectExceptionCode(0);
|
||||
$this->expectExceptionMessage(
|
||||
'An error occurred while trying to download a fresh copy of the GeoLite2 database'
|
||||
);
|
||||
@@ -73,6 +74,7 @@ class DbUpdaterTest extends TestCase
|
||||
$request = $this->httpClient->request(Argument::cetera())->willReturn(new Response());
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->expectExceptionCode(0);
|
||||
$this->expectExceptionMessage(
|
||||
'An error occurred while trying to extract the GeoLite2 database from __invalid__/GeoLite2-City.tar.gz'
|
||||
);
|
||||
@@ -91,6 +93,7 @@ class DbUpdaterTest extends TestCase
|
||||
$copy = $this->filesystem->copy(Argument::cetera())->willThrow($e);
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->expectExceptionCode(0);
|
||||
$this->expectExceptionMessage('An error occurred while trying to copy GeoLite2 db file to destination');
|
||||
$request->shouldBeCalledOnce();
|
||||
$copy->shouldBeCalledOnce();
|
||||
|
||||
@@ -41,6 +41,7 @@ class GeoLite2LocationResolverTest extends TestCase
|
||||
|
||||
$this->expectException(WrongIpException::class);
|
||||
$this->expectExceptionMessage($message);
|
||||
$this->expectExceptionCode(0);
|
||||
$cityMethod->shouldBeCalledOnce();
|
||||
|
||||
$this->resolver->resolveIpLocation($ipAddress);
|
||||
|
||||
29
module/Common/test/Response/PixelResponseTest.php
Normal file
29
module/Common/test/Response/PixelResponseTest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Common\Response;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shlinkio\Shlink\Common\Response\PixelResponse;
|
||||
|
||||
class PixelResponseTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var PixelResponse
|
||||
*/
|
||||
private $resp;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->resp = new PixelResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function responseHasGifTypeAndIsNotEmpty()
|
||||
{
|
||||
$this->assertEquals('image/gif', $this->resp->getHeaderLine('Content-Type'));
|
||||
$this->assertNotEmpty((string) $this->resp->getBody());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user