Skip to content

Commit

Permalink
Delete CbpStrategy sortParams()
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoologic committed Nov 17, 2023
1 parent 685ea92 commit c1bb176
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CBP_UPGRADE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Note the query parameters change in these two URL examples:

### CBP ordering

When moving from OBP to CBP sorting params change as well:
When moving from OBP to CBP sorting params _may_ change as well:

- From: `?sort_name=updated_at&sort_order=desc`
- To: `sort=-updated_at`
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ foreach ($iterator as $ticket) {
* Refer to the docs for details, including allowed sort fields
* Combine everything: `$params = ['page[size]' => 2, 'sort' => 'updated_at', 'extra' => 'param'];`

**Note**: Refer to the documentation for the correct params for sorting with the pagination type you're using.

##### Iterator API call response

The latest response is exposed in the iterator at `$iterator->latestResponse()`. This could come handy for debugging.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,6 @@ public function testFetchesCbpWithParams()
], $mockTickets->params);
}

public function testCorrectsParamsToCbp()
{
$mockTickets = new MockResource('tickets', [
[['id' => 1], ['id' => 2]],
[['id' => 3], ['id' => 4]]
]);
$strategy = new CbpStrategy('tickets', ['per_page' => 2, 'sort_by' => 'id', 'sort_order' => 'desc']);
$iterator = new PaginationIterator($mockTickets, $strategy, 'findAll');

iterator_to_array($iterator);

$this->assertEquals([
'sort' => '-id',
'page[size]' => 2, 'page[after]' => 'cursor_for_next_page'
], $mockTickets->params);
}

public function testFetchesSinglePageWithParams()
{
$resultsKey = 'results';
Expand Down

0 comments on commit c1bb176

Please sign in to comment.