Skip to content

Commit

Permalink
Fix ClassNameExample suggestion from ClassResolverExceptionTrait
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemaclass committed Jul 25, 2023
1 parent b36f53d commit 56d4953
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Framework/ClassResolver/ClassResolverExceptionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ private function buildMessage(object|string $caller, string $resolvableType): st
private function findClassNameExample(ClassInfo $classInfo, string $resolvableType): string
{
return sprintf(
'\\%s\\%s',
'\\%s\\%s\\%s',
$classInfo->getModuleNamespace(),
$classInfo->getModuleName(),
$resolvableType,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
namespace GacelaTest\Unit\Framework\ClassResolver\DependencyProvider;

use Gacela\Framework\ClassResolver\DependencyProvider\DependencyProviderNotFoundException;
use GacelaTest\Unit\FakeModule\FakeFacade;
use PHPUnit\Framework\TestCase;

final class DependencyProviderNotFoundExceptionTest extends TestCase
{
public function test_exception_message(): void
{
$exception = new DependencyProviderNotFoundException($this);
$facade = new FakeFacade();

$exception = new DependencyProviderNotFoundException($facade);

$expected = <<<EOT
ClassResolver Exception
Cannot resolve the `DependencyProvider` for your module `DependencyProvider`
Cannot resolve the `DependencyProvider` for your module `FakeModule`
You can fix this by adding the missing `DependencyProvider` to your module.
E.g. `\GacelaTest\Unit\Framework\ClassResolver\DependencyProvider`
E.g. `\GacelaTest\Unit\FakeModule\DependencyProvider`
EOT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,28 @@

declare(strict_types=1);


namespace GacelaTest\Unit\Framework\ClassResolver\DocBlockService;

use Gacela\Framework\ClassResolver\DocBlockService\DocBlockServiceNotFoundException;
use GacelaTest\Unit\FakeModule\FakeFacade;
use PHPUnit\Framework\TestCase;

final class DocBlockServiceNotFoundExceptionTest
final class DocBlockServiceNotFoundExceptionTest extends TestCase
{
public function test_exception_message(): void
{
$facade = new FakeFacade();

$exception = new DocBlockServiceNotFoundException($facade, 'ResolvableType');

$expected = <<<EOT
ClassResolver Exception
Cannot resolve the `ResolvableType` for your module `FakeModule`
You can fix this by adding the missing `ResolvableType` to your module.
E.g. `\GacelaTest\Unit\FakeModule\ResolvableType`
EOT;

self::assertSame($expected, $exception->getMessage());
}
}

0 comments on commit 56d4953

Please sign in to comment.