Skip to content

Commit

Permalink
Create test for sources
Browse files Browse the repository at this point in the history
  • Loading branch information
cerbero90 committed Jan 21, 2024
1 parent c015b5b commit 9d9392f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/Feature/SourceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Cerbero\LazyJsonPages\LazyJsonPages;

it('supports multiple sources', function (mixed $source) {
$expectedItems = require_once fixture('items.php');
$lazyCollection = LazyJsonPages::from($source)
->totalPages('meta.total_pages')
->collect('data.*');

expect($lazyCollection)->toLoadItemsViaRequests($expectedItems, [
'https://example.com/api/v1/users' => 'totalPages/page1.json',
'https://example.com/api/v1/users?page=2' => 'totalPages/page2.json',
'https://example.com/api/v1/users?page=3' => 'totalPages/page3.json',
]);
})->with('sources');

0 comments on commit 9d9392f

Please sign in to comment.