Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
Новый общий эксепшн для идентификации исключения в приложении
Browse files Browse the repository at this point in the history
  • Loading branch information
fenric committed Oct 15, 2018
1 parent 84706ae commit 30777ef
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 13 deletions.
25 changes: 25 additions & 0 deletions src/Exception/Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php declare(strict_types=1);

/**
* It's free open-source software released under the MIT License.
*
* @author Anatoly Fenric <anatoly@fenric.ru>
* @copyright Copyright (c) 2018, Anatoly Fenric
* @license https://github.com/sunrise-php/uri/blob/master/LICENSE
* @link https://github.com/sunrise-php/uri
*/

namespace Sunrise\Uri\Exception;

/**
* Import classes
*/
use RuntimeException;

/**
* Exception
*
* @package Sunrise\Uri
*/
class Exception extends RuntimeException
{}
7 changes: 1 addition & 6 deletions src/Exception/InvalidUriComponentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@

namespace Sunrise\Uri\Exception;

/**
* Import classes
*/
use RuntimeException;

/**
* InvalidUriComponentException
*
* @package Sunrise\Uri
*/
class InvalidUriComponentException extends RuntimeException
class InvalidUriComponentException extends Exception
{}
7 changes: 1 addition & 6 deletions src/Exception/InvalidUriException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@

namespace Sunrise\Uri\Exception;

/**
* Import classes
*/
use RuntimeException;

/**
* InvalidUriException
*
* @package Sunrise\Uri
*/
class InvalidUriException extends RuntimeException
class InvalidUriException extends Exception
{}
26 changes: 25 additions & 1 deletion tests/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PHPUnit\Framework\TestCase;
use Sunrise\Collection\CollectionInterface;
use Sunrise\Uri\Exception\Exception;
use Sunrise\Uri\Exception\InvalidUriComponentException;
use Sunrise\Uri\Exception\InvalidUriException;
use Sunrise\Uri\Uri;
Expand All @@ -26,7 +27,7 @@ public function testConstructorWithInvalidUri()
{
$this->expectException(InvalidUriException::class);

$uri = new Uri(':');
new Uri(':');
}

// Getters...
Expand Down Expand Up @@ -423,4 +424,27 @@ public function testUpdatePayload()

$this->assertEquals(['new-string' => 'new-value'], $uri->getPayload()->toArray());
}

// Exceptions...

public function testException()
{
$this->expectException(\RuntimeException::class);

new Uri(':');
}

public function testInvalidUriException()
{
$this->expectException(Exception::class);

new Uri(':');
}

public function testInvalidUriComponentException()
{
$this->expectException(Exception::class);

(new Uri(self::TEST_URI))->setScheme('scheme://');
}
}

0 comments on commit 30777ef

Please sign in to comment.