-
-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create FixtureNotFoundException for resolver context (#713)
- Loading branch information
Showing
6 changed files
with
142 additions
and
1 deletion.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
fixtures/Throwable/Exception/Generator/Resolver/ChildFixtureNotFoundException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Alice package. | ||
* | ||
* (c) Nelmio <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Nelmio\Alice\Throwable\Exception\Generator\Resolver; | ||
|
||
class ChildFixtureNotFoundException extends FixtureNotFoundException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Throwable/Exception/Generator/Resolver/FixtureNotFoundException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Alice package. | ||
* | ||
* (c) Nelmio <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nelmio\Alice\Throwable\Exception\Generator\Resolver; | ||
|
||
use Nelmio\Alice\Throwable\ResolutionThrowable; | ||
|
||
class FixtureNotFoundException extends \RuntimeException implements ResolutionThrowable | ||
{ | ||
} |
30 changes: 30 additions & 0 deletions
30
src/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Alice package. | ||
* | ||
* (c) Nelmio <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nelmio\Alice\Throwable\Exception\Generator\Resolver; | ||
|
||
/** | ||
* @private | ||
*/ | ||
final class FixtureNotFoundExceptionFactory | ||
{ | ||
public static function create(string $id): FixtureNotFoundException | ||
{ | ||
return new FixtureNotFoundException( | ||
sprintf( | ||
'Could not find the fixture "%s".', | ||
$id | ||
) | ||
); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
tests/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionFactoryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Alice package. | ||
* | ||
* (c) Nelmio <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nelmio\Alice\Throwable\Exception\Generator\Resolver; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\FixtureNotFoundExceptionFactory | ||
*/ | ||
class FixtureNotFoundExceptionFactoryTest extends TestCase | ||
{ | ||
public function testTestCreateNewExceptionWithFactory() | ||
{ | ||
$exception = FixtureNotFoundExceptionFactory::create('foo'); | ||
|
||
$this->assertEquals( | ||
'Could not find the fixture "foo".', | ||
$exception->getMessage() | ||
); | ||
$this->assertEquals(0, $exception->getCode()); | ||
$this->assertNull($exception->getPrevious()); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
tests/Throwable/Exception/Generator/Resolver/FixtureNotFoundExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Alice package. | ||
* | ||
* (c) Nelmio <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nelmio\Alice\Throwable\Exception\Generator\Resolver; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Nelmio\Alice\Throwable\ResolutionThrowable; | ||
|
||
/** | ||
* @covers \Nelmio\Alice\Throwable\Exception\Generator\Resolver\FixtureNotFoundException | ||
*/ | ||
class FixtureNotFoundExceptionTest extends TestCase | ||
{ | ||
public function testIsARuntimeException() | ||
{ | ||
$this->assertTrue(is_a(FixtureNotFoundException::class, \RuntimeException::class, true)); | ||
} | ||
|
||
public function testIsAResolutionThrowable() | ||
{ | ||
$this->assertTrue(is_a(FixtureNotFoundException::class, ResolutionThrowable::class, true)); | ||
} | ||
|
||
public function testIsExtensible() | ||
{ | ||
$exception = new ChildFixtureNotFoundException(); | ||
$this->assertInstanceOf(ChildFixtureNotFoundException::class, $exception); | ||
} | ||
} |