Increased MSI to 64%

This commit is contained in:
Alejandro Celaya
2018-11-17 18:40:47 +01:00
parent d2ed7d6417
commit 6094d17718
10 changed files with 103 additions and 42 deletions

View 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());
}
}

View File

@@ -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();

View File

@@ -41,6 +41,7 @@ class GeoLite2LocationResolverTest extends TestCase
$this->expectException(WrongIpException::class);
$this->expectExceptionMessage($message);
$this->expectExceptionCode(0);
$cityMethod->shouldBeCalledOnce();
$this->resolver->resolveIpLocation($ipAddress);

View 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());
}
}