Skip to content

Commit

Permalink
Create FixtureNotFoundException for resolver context (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
ossinkine authored and theofidry committed Apr 11, 2017
1 parent 4d47f90 commit 056f173
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 1 deletion.
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
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use Nelmio\Alice\Definition\Object\CompleteObject;
use Nelmio\Alice\Definition\Value\FixtureReferenceValue;
use Nelmio\Alice\Definition\ValueInterface;
use Nelmio\Alice\Throwable\Exception\FixtureNotFoundExceptionFactory;
use Nelmio\Alice\Throwable\Exception\Generator\ObjectGenerator\ObjectGeneratorNotFoundExceptionFactory;
use Nelmio\Alice\Throwable\Exception\Generator\Resolver\FixtureNotFoundExceptionFactory;
use Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueException;
use Nelmio\Alice\FixtureIdInterface;
use Nelmio\Alice\FixtureInterface;
Expand Down
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
{
}
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
)
);
}
}
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());
}
}
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);
}
}

0 comments on commit 056f173

Please sign in to comment.