Skip to content

Commit

Permalink
Fix one failing test on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypkhantc committed Aug 27, 2024
1 parent e0880c4 commit 6472775
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/AggregateControllerQueryProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use function array_values;
use function assert;
use function count;
use function sort;

/**
* A query provider that looks into all controllers of your application to fetch queries.
Expand Down Expand Up @@ -90,7 +91,8 @@ private function flattenList(array $list): array

// We have an issue, let's detect the duplicate
$queriesByName = [];
$duplicate = null;
$duplicateClasses = null;
$duplicateQueryName = null;

foreach ($list as $class => $queries) {
foreach ($queries as $query => $field) {
Expand All @@ -102,12 +104,15 @@ private function flattenList(array $list): array
continue;
}

$duplicate = [$duplicatedClass, $class, $query];
$duplicateClasses = [$duplicatedClass, $class];
$duplicateQueryName = $query;
}
}

assert($duplicate !== null);
assert($duplicateClasses !== null && $duplicateQueryName !== null);

throw DuplicateMappingException::createForQueryInTwoControllers($duplicate[0], $duplicate[1], $duplicate[2]);
sort($duplicateClasses);

throw DuplicateMappingException::createForQueryInTwoControllers($duplicateClasses[0], $duplicateClasses[1], $duplicateQueryName);
}
}
3 changes: 3 additions & 0 deletions src/Reflection/DocBlock/DocBlockFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@

interface DocBlockFactory
{
/**
* Fetches a DocBlock object from a ReflectionMethod
*/
public function createFromReflector(ReflectionClass|ReflectionMethod|ReflectionProperty|ReflectionClassConstant $reflector): DocBlock;
}
4 changes: 2 additions & 2 deletions tests/Reflection/CachedDocBlockFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public function testGetDocBlock(): void
)
);

$refMethod = new ReflectionMethod(AnnotationReader::class, 'getMethodAnnotation');
$refMethod = new ReflectionMethod(DocBlockFactory::class, 'createFromReflector');

$docBlock = $cachedDocBlockFactory->createFromReflector($refMethod);
$this->assertSame('Returns a method annotation and handles correctly errors.', $docBlock->getSummary());
$this->assertSame('Fetches a DocBlock object from a ReflectionMethod', $docBlock->getSummary());
$docBlock2 = $cachedDocBlockFactory->createFromReflector($refMethod);
$this->assertSame($docBlock2, $docBlock);

Expand Down

0 comments on commit 6472775

Please sign in to comment.