21use PHPUnit\Framework\MockObject\MockObject;
60 protected function setUp(): void
64 $this->resource_builder = $this->createMock(ResourceBuilder::class);
72 $resource_one = $this->createMock(StorableFileResource::class);
73 $this->revision_one = $this->createMock(Revision::class);
76 $resource_two = $this->createMock(StorableFileResource::class);
77 $this->revision_two = $this->createMock(Revision::class);
80 $resource_three = $this->createMock(StorableFileResource::class);
81 $this->revision_three = $this->createMock(Revision::class);
83 $this->sorter =
new Sorter(
84 $this->resource_builder,
85 $this->createStub(CollectionBuilder::class),
90 $collection->add($this->rid_one);
91 $collection->add($this->rid_two);
92 $collection->add($this->rid_three);
95 $resource_one->expects($this->atLeastOnce())
96 ->method(
'getCurrentRevision')
97 ->willReturn($this->revision_one);
99 $resource_two->expects($this->atLeastOnce())
100 ->method(
'getCurrentRevision')
101 ->willReturn($this->revision_two);
103 $resource_three->expects($this->atLeastOnce())
104 ->method(
'getCurrentRevision')
105 ->willReturn($this->revision_three);
113 $this->resource_builder->expects($this->atLeastOnce())
115 ->willReturnMap($map);
120 $this->revision_one->expects($this->atLeastOnce())
121 ->method(
'getInformation')
123 $this->revision_two->expects($this->atLeastOnce())
124 ->method(
'getInformation')
126 $this->revision_three->expects($this->atLeastOnce())
127 ->method(
'getInformation')
128 ->willReturn($three);
139 $sorted_collection = $this->sorter->desc()->bySize();
142 $this->rid_three->serialize(),
143 $this->rid_two->serialize(),
144 $this->rid_one->serialize()
146 $this->getFlatOrder($sorted_collection)
158 $sorted_collection = $this->sorter->asc()->bySize();
161 $this->rid_one->serialize(),
162 $this->rid_two->serialize(),
163 $this->rid_three->serialize(),
165 $this->getFlatOrder($sorted_collection)
177 $sorted_collection = $this->sorter->bySize();
180 $this->rid_one->serialize(),
181 $this->rid_two->serialize(),
182 $this->rid_three->serialize(),
184 $this->getFlatOrder($sorted_collection)
192 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-01-01')),
193 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-02-02')),
194 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-03-03'))
196 $sorted_collection = $this->sorter->byCreationDate();
199 $this->rid_one->serialize(),
200 $this->rid_two->serialize(),
201 $this->rid_three->serialize(),
203 $this->getFlatOrder($sorted_collection)
211 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-01-01')),
212 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-02-02')),
213 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-03-03'))
215 $sorted_collection = $this->sorter->asc()->byCreationDate();
218 $this->rid_one->serialize(),
219 $this->rid_two->serialize(),
220 $this->rid_three->serialize(),
222 $this->getFlatOrder($sorted_collection)
230 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-01-01')),
231 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-02-02')),
232 (
new FileInformation())->setCreationDate(
new \DateTimeImmutable(
'2020-03-03'))
234 $sorted_collection = $this->sorter->desc()->byCreationDate();
237 $this->rid_three->serialize(),
238 $this->rid_two->serialize(),
239 $this->rid_one->serialize(),
241 $this->getFlatOrder($sorted_collection)
253 $sorted_collection = $this->sorter->byTitle();
256 $this->rid_one->serialize(),
257 $this->rid_two->serialize(),
258 $this->rid_three->serialize(),
260 $this->getFlatOrder($sorted_collection)
272 $sorted_collection = $this->sorter->asc()->byTitle();
275 $this->rid_one->serialize(),
276 $this->rid_two->serialize(),
277 $this->rid_three->serialize(),
279 $this->getFlatOrder($sorted_collection)
291 $sorted_collection = $this->sorter->desc()->byTitle();
294 $this->rid_three->serialize(),
295 $this->rid_two->serialize(),
296 $this->rid_one->serialize(),
298 $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...