21use PHPUnit\Framework\MockObject\MockObject;
51 protected function setUp(): void
55 $this->resource_builder = $this->createMock(ResourceBuilder::class);
56 $collection_builder = $this->createMock(CollectionBuilder::class);
64 $resource_one = $this->createMock(StorableFileResource::class);
65 $this->revision_one = $this->createMock(Revision::class);
68 $resource_two = $this->createMock(StorableFileResource::class);
69 $this->revision_two = $this->createMock(Revision::class);
72 $resource_three = $this->createMock(StorableFileResource::class);
73 $this->revision_three = $this->createMock(Revision::class);
75 $this->sorter =
new Sorter(
76 $this->resource_builder,
82 $collection->add($this->rid_one);
83 $collection->add($this->rid_two);
84 $collection->add($this->rid_three);
87 $resource_one->expects($this->atLeastOnce())
88 ->method(
'getCurrentRevision')
89 ->willReturn($this->revision_one);
91 $resource_two->expects($this->atLeastOnce())
92 ->method(
'getCurrentRevision')
93 ->willReturn($this->revision_two);
95 $resource_three->expects($this->atLeastOnce())
96 ->method(
'getCurrentRevision')
97 ->willReturn($this->revision_three);
105 $this->resource_builder->expects($this->atLeastOnce())
107 ->willReturnMap($map);
112 $this->revision_one->expects($this->atLeastOnce())
113 ->method(
'getInformation')
115 $this->revision_two->expects($this->atLeastOnce())
116 ->method(
'getInformation')
118 $this->revision_three->expects($this->atLeastOnce())
119 ->method(
'getInformation')
120 ->willReturn($three);
131 $sorted_collection = $this->sorter->desc()->bySize();
134 $this->rid_three->serialize(),
135 $this->rid_two->serialize(),
136 $this->rid_one->serialize()
138 $this->getFlatOrder($sorted_collection)
150 $sorted_collection = $this->sorter->asc()->bySize();
153 $this->rid_one->serialize(),
154 $this->rid_two->serialize(),
155 $this->rid_three->serialize(),
157 $this->getFlatOrder($sorted_collection)
169 $sorted_collection = $this->sorter->bySize();
172 $this->rid_one->serialize(),
173 $this->rid_two->serialize(),
174 $this->rid_three->serialize(),
176 $this->getFlatOrder($sorted_collection)
184 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-01-01')),
185 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-02-02')),
186 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-03-03'))
188 $sorted_collection = $this->sorter->byCreationDate();
191 $this->rid_one->serialize(),
192 $this->rid_two->serialize(),
193 $this->rid_three->serialize(),
195 $this->getFlatOrder($sorted_collection)
203 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-01-01')),
204 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-02-02')),
205 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-03-03'))
207 $sorted_collection = $this->sorter->asc()->byCreationDate();
210 $this->rid_one->serialize(),
211 $this->rid_two->serialize(),
212 $this->rid_three->serialize(),
214 $this->getFlatOrder($sorted_collection)
222 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-01-01')),
223 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-02-02')),
224 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-03-03'))
226 $sorted_collection = $this->sorter->desc()->byCreationDate();
229 $this->rid_three->serialize(),
230 $this->rid_two->serialize(),
231 $this->rid_one->serialize(),
233 $this->getFlatOrder($sorted_collection)
245 $sorted_collection = $this->sorter->byTitle();
248 $this->rid_one->serialize(),
249 $this->rid_two->serialize(),
250 $this->rid_three->serialize(),
252 $this->getFlatOrder($sorted_collection)
264 $sorted_collection = $this->sorter->asc()->byTitle();
267 $this->rid_one->serialize(),
268 $this->rid_two->serialize(),
269 $this->rid_three->serialize(),
271 $this->getFlatOrder($sorted_collection)
283 $sorted_collection = $this->sorter->desc()->byTitle();
286 $this->rid_three->serialize(),
287 $this->rid_two->serialize(),
288 $this->rid_one->serialize(),
290 $this->getFlatOrder($sorted_collection)
Class AbstractBaseResourceBuilderTestCase.
Class ResourceCollection.
getResourceIdentifications()
Class ResourceCollectionIdentification.
Class ResourceIdentification.
Class CollectionSortingTest.
testByCreationDateDescSorting()
setUpRevisionExpectations(FileInformation $one, FileInformation $two, FileInformation $three)
CollectionIdentificationGenerator $rcid_generator
ResourceIdentification $rid_three
getFlatOrder(ResourceCollection $collection)
testBySizeDefaultSorting()
testByTitleDefaultSorting()
ResourceIdentification $rid_one
testByCreationDateDefaultSorting()
MockObject $revision_three
testByCreationDateAscSorting()
ResourceIdentification $rid_two
Class CollectionIdentificationGenerator.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...