More CollectionsService tests

This commit is contained in:
Jeremy Dormitzer 2019-01-20 17:35:33 -05:00
parent ed46ec1e1f
commit 5e979c4236

View File

@ -79,6 +79,121 @@ class CollectionsServiceTest extends TestCase
),
),
),
array(
'id' => 'moreThanOnePage',
'collection' => array(
'@context' => array(
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
),
'id' => 'https://example.com/objects/1',
'type' => 'OrderedCollection',
'orderedItems' => array(
array(
'id' => 'https://example.com/objects/2',
),
array(
'id' => 'https://example.com/objects/3',
),
array(
'id' => 'https://example.com/objects/4',
),
array(
'id' => 'https://example.com/objects/5',
),
array(
'id' => 'https://example.com/objects/6',
),
)
),
'request' => Request::create(
'https://example.com/objects/1',
Request::METHOD_GET
),
'expectedResult' => array(
'@context' => array(
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
),
'id' => 'https://example.com/objects/1',
'type' => 'OrderedCollection',
'first' => array(
'@context' => array(
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
),
'id' => 'https://example.com/objects/1?offset=0',
'type' => 'OrderedCollectionPage',
'partOf' => 'https://example.com/objects/1',
'startIndex' => 0,
'next' => 'https://example.com/objects/1?offset=4',
'orderedItems' => array(
array(
'id' => 'https://example.com/objects/2',
),
array(
'id' => 'https://example.com/objects/3',
),
array(
'id' => 'https://example.com/objects/4',
),
array(
'id' => 'https://example.com/objects/5',
),
),
),
),
),
array(
'id' => 'notFirstPage',
'collection' => array(
'@context' => array(
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
),
'id' => 'https://example.com/objects/1',
'type' => 'OrderedCollection',
'orderedItems' => array(
array(
'id' => 'https://example.com/objects/2',
),
array(
'id' => 'https://example.com/objects/3',
),
array(
'id' => 'https://example.com/objects/4',
),
array(
'id' => 'https://example.com/objects/5',
),
array(
'id' => 'https://example.com/objects/6',
),
)
),
'request' => Request::create(
'https://example.com/objects/1?offset=3',
Request::METHOD_GET,
),
'expectedResult' => array(
'@context' => array(
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
),
'id' => 'https://example.com/objects/1?offset=3',
'type' => 'OrderedCollectionPage',
'partOf' => 'https://example.com/objects/1',
'startIndex' => 3,
'orderedItems' => array(
array(
'id' => 'https://example.com/objects/5',
),
array(
'id' => 'https://example.com/objects/6',
),
),
),
),
);
foreach ( $testCases as $testCase ) {
$actual = $this->collectionsService->pageAndFilterCollection(