mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-05 20:57:12 +00:00
Merge 4b0b7503c5 into cbb32838fb
This commit is contained in:
commit
27dec182dd
2 changed files with 33 additions and 1 deletions
|
|
@ -44,6 +44,6 @@ final class UriBasedSectionProvider implements SectionProviderInterface
|
|||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
throw new SectionCannotBeResolvedException(sprintf('Section cannot be resolved for URI "%s".', $uri));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,4 +88,36 @@ final class UriBasedSectionProviderTest extends TestCase
|
|||
$this->requestStack->expects($this->once())->method('getMainRequest')->willReturn(null);
|
||||
$this->assertNull($this->uriBasedSectionProvider->getSection());
|
||||
}
|
||||
|
||||
public function testThrowsExceptionIfNoResolverCanHandleTheUri(): void
|
||||
{
|
||||
$request = $this->createMock(Request::class);
|
||||
|
||||
$this->requestStack
|
||||
->expects($this->once())
|
||||
->method('getMainRequest')
|
||||
->willReturn($request);
|
||||
$request
|
||||
->expects($this->once())
|
||||
->method('getPathInfo')
|
||||
->willReturn('/unknown-section');
|
||||
|
||||
$this->firstSectionResolver
|
||||
->expects($this->once())
|
||||
->method('getSection')
|
||||
->with('/unknown-section')
|
||||
->willThrowException(new SectionCannotBeResolvedException())
|
||||
;
|
||||
|
||||
$this->secondSectionResolver
|
||||
->expects($this->once())
|
||||
->method('getSection')
|
||||
->with('/unknown-section')
|
||||
->willThrowException(new SectionCannotBeResolvedException())
|
||||
;
|
||||
|
||||
$this->expectException(SectionCannotBeResolvedException::class);
|
||||
|
||||
$this->uriBasedSectionProvider->getSection();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue