2 declare(strict_types = 1);
19 use PHPUnit\Framework\MockObject\MockObject;
20 use Prophecy\Prophecy\ObjectProphecy;
27 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
56 protected function setUp()
59 $this->languageProphecy = $this->prophesize(
62 $this->siteProphecy = $this->prophesize(
65 $this->persistedMockClass = $this->getMockClass(
66 PersistedMappableAspectInterface::class
68 $this->aspectMockClass = $this->getMockClass(
69 AspectInterface::class
71 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'routing'][
'aspects'] = [
76 $contextMock = $this->getMockBuilder(Context::class)
77 ->disableOriginalConstructor()
84 unset($this->subject, $this->languageProphecy, $this->persistedMockClass, $this->aspectMockClass);
93 $this->expectException(\InvalidArgumentException::class);
94 $this->expectExceptionCode(1538079481);
95 $this->subject->createAspects(
97 $this->languageProphecy->reveal(),
98 $this->siteProphecy->reveal()
107 $this->expectException(\OutOfRangeException::class);
108 $this->expectExceptionCode(1538079482);
109 $this->subject->createAspects(
110 [
'a' => [
'type' =>
'Undefined']],
111 $this->languageProphecy->reveal(),
112 $this->siteProphecy->reveal()
124 'a' => [
'type' =>
'Aspect'],
127 'a' => AspectInterface::class,
130 'both non-persisted' => [
132 'a' => [
'type' =>
'Aspect'],
133 'b' => [
'type' =>
'Aspect'],
136 'a' => AspectInterface::class,
137 'b' => AspectInterface::class,
140 'both persisted' => [
142 'a' => [
'type' =>
'Persisted'],
143 'b' => [
'type' =>
'Persisted'],
146 'a' => PersistedMappableAspectInterface::class,
147 'b' => PersistedMappableAspectInterface::class,
151 'first persisted, second non-persisted' => [
153 'a' => [
'type' =>
'Persisted'],
154 'b' => [
'type' =>
'Aspect'],
157 'b' => AspectInterface::class,
158 'a' => PersistedMappableAspectInterface::class,
162 'many persisted, many non-persisted' => [
164 'a' => [
'type' =>
'Persisted'],
165 'b' => [
'type' =>
'Aspect'],
166 'c' => [
'type' =>
'Persisted'],
167 'd' => [
'type' =>
'Aspect'],
170 'b' => AspectInterface::class,
171 'd' => AspectInterface::class,
172 'a' => PersistedMappableAspectInterface::class,
173 'c' => PersistedMappableAspectInterface::class,
188 $aspects = $this->subject->createAspects(
190 $this->languageProphecy->reveal(),
191 $this->siteProphecy->reveal()
193 static::assertSame(array_keys($aspects), array_keys($expectation));
194 array_walk($aspects,
function ($aspect, $key) use ($expectation) {
195 static::assertInstanceOf($expectation[$key], $aspect);