Skip to content

Commit

Permalink
Improvements on Exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandoorn committed Jul 11, 2017
1 parent 112681c commit 6a4e0a0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Exception/RouteExistsException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

namespace SitemapPlugin\Exception;

/**
Expand All @@ -12,6 +12,6 @@ class RouteExistsException extends \Exception
*/
public function __construct($routeName, \Exception $previousException = null)
{
parent::__construct(sprintf('Sitemap route %s already exists, probably a provider with a non-unique name', $routeName), 0, $previousException);
parent::__construct(sprintf('Sitemap route "%s" already exists, probably a provider with a non-unique name', $routeName), 0, $previousException);
}
}
5 changes: 3 additions & 2 deletions src/Exception/SitemapUrlNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace SitemapPlugin\Exception;

use SitemapPlugin\Model\SitemapUrlInterface;

/**
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
* @author Stefan Doorn <stefan@efectos.nl>
*/
class SitemapUrlNotFoundException extends \Exception
{
Expand All @@ -14,6 +15,6 @@ class SitemapUrlNotFoundException extends \Exception
*/
public function __construct(SitemapUrlInterface $sitemapUrl, \Exception $previousException = null)
{
parent::__construct(sprintf('Sitemap url %s not found', $sitemapUrl->getLocalization()), 0, $previousException);
parent::__construct(sprintf('Sitemap url "%s" not found', $sitemapUrl->getLocalization()), 0, $previousException);
}
}
20 changes: 20 additions & 0 deletions tests/Exception/RouteExistsExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Tests\SitemapPlugin\Exception;

use SitemapPlugin\Exception\RouteExistsException;

/**
* @author Stefan Doorn <stefan@efectos.nl>
*/
class RouteExistsExceptionTest extends \PHPUnit_Framework_TestCase
{
/**
*
*/
public function testException()
{
$exception = new RouteExistsException('test');
$this->assertSame('Sitemap route "test" already exists, probably a provider with a non-unique name', $exception->getMessage());
}
}
25 changes: 25 additions & 0 deletions tests/Exception/SitemapUrlNotFoundExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Tests\SitemapPlugin\Exception;

use SitemapPlugin\Exception\RouteExistsException;
use SitemapPlugin\Exception\SitemapUrlNotFoundException;
use SitemapPlugin\Model\SitemapUrl;

/**
* @author Stefan Doorn <stefan@efectos.nl>
*/
class SitemapUrlNotFoundExceptionTest extends \PHPUnit_Framework_TestCase
{
/**
*
*/
public function testException()
{
$sitemapUrl = new SitemapUrl();
$sitemapUrl->setLocalization('test');

$exception = new SitemapUrlNotFoundException($sitemapUrl);
$this->assertSame('Sitemap url "test" not found', $exception->getMessage());
}
}

0 comments on commit 6a4e0a0

Please sign in to comment.