mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 17:41:50 +01:00
74 lines
2.5 KiB
PHP
74 lines
2.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* (c) Meritoo.pl, http://www.meritoo.pl
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Meritoo\Common\Test\Exception\Reflection;
|
|
|
|
use Generator;
|
|
use Meritoo\Common\Exception\Reflection\CannotResolveClassNameException;
|
|
use Meritoo\Common\Test\Base\BaseTestCase;
|
|
use Meritoo\Common\Type\OopVisibilityType;
|
|
|
|
/**
|
|
* Test case of an exception used while name of class or trait cannot be resolved
|
|
*
|
|
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
|
* @copyright Meritoo.pl
|
|
*/
|
|
class CannotResolveClassNameExceptionTest extends BaseTestCase
|
|
{
|
|
public function testConstructorVisibilityAndArguments()
|
|
{
|
|
static::assertConstructorVisibilityAndArguments(CannotResolveClassNameException::class, OopVisibilityType::IS_PUBLIC, 2, 1);
|
|
}
|
|
|
|
/**
|
|
* @param array|object|string $source Source of the class's / trait's name. It can be an array of objects,
|
|
* namespaces, object or namespace.
|
|
* @param bool $forClass If is set to true, message of this exception for class is prepared.
|
|
* Otherwise - for trait.
|
|
* @param string $expectedMessage Expected exception's message
|
|
*
|
|
* @dataProvider provideClassName
|
|
*/
|
|
public function testConstructorMessage($source, $forClass, $expectedMessage)
|
|
{
|
|
$exception = new CannotResolveClassNameException($source, $forClass);
|
|
static::assertEquals($expectedMessage, $exception->getMessage());
|
|
}
|
|
|
|
/**
|
|
* Provides source of the class's / trait's name, information if message of this exception should be prepared for
|
|
* class and the expected exception's message
|
|
*
|
|
* @return Generator
|
|
*/
|
|
public function provideClassName()
|
|
{
|
|
yield[
|
|
'Not\Existing\Class',
|
|
true,
|
|
'Name of class from given \'string\' Not\Existing\Class cannot be resolved. Is there everything ok?',
|
|
];
|
|
|
|
yield[
|
|
'Not\Existing\Trait',
|
|
false,
|
|
'Name of trait from given \'string\' Not\Existing\Trait cannot be resolved. Is there everything ok?',
|
|
];
|
|
|
|
yield[
|
|
[
|
|
new \stdClass(),
|
|
new \stdClass(),
|
|
],
|
|
true,
|
|
'Name of class from given \'array\' cannot be resolved. Is there everything ok?',
|
|
];
|
|
}
|
|
}
|