|
34 | 34 | ->and($response['total'])->toBe(10); |
35 | 35 | }); |
36 | 36 |
|
| 37 | +test('getParams returns default values when no params provided', function () { |
| 38 | + |
| 39 | + $contacts = new Contacts(); |
| 40 | + $reflection = new ReflectionMethod(Contacts::class, 'getParams'); |
| 41 | + $response = $reflection->invoke($contacts, [], 25); |
| 42 | + |
| 43 | + parse_str($response, $parsedParams); |
| 44 | + |
| 45 | + expect($parsedParams)->toMatchArray([ |
| 46 | + '$orderby' => 'displayName', |
| 47 | + '$top' => '25', |
| 48 | + '$skip' => '0', |
| 49 | + '$count' => 'true', |
| 50 | + ]); |
| 51 | +}); |
| 52 | + |
| 53 | +test('getParams includes custom top parameter', function () { |
| 54 | + $contacts = new Contacts(); |
| 55 | + $reflection = new ReflectionMethod(Contacts::class, 'getParams'); |
| 56 | + $response = $reflection->invoke($contacts, ['$top' => 10], 25); |
| 57 | + |
| 58 | + parse_str($response, $parsedParams); |
| 59 | + |
| 60 | + expect($parsedParams)->toMatchArray([ |
| 61 | + '$top' => '10', |
| 62 | + '$skip' => '0', |
| 63 | + '$count' => 'true', |
| 64 | + ]); |
| 65 | +}); |
| 66 | + |
| 67 | +test('getParams includes custom skip parameter', function () { |
| 68 | + $contacts = new Contacts(); |
| 69 | + $reflection = new ReflectionMethod(Contacts::class, 'getParams'); |
| 70 | + $response = $reflection->invoke($contacts, ['$skip' => 15], 25); |
| 71 | + |
| 72 | + parse_str($response, $parsedParams); |
| 73 | + |
| 74 | + expect($parsedParams)->toMatchArray([ |
| 75 | + '$top' => '25', |
| 76 | + '$skip' => '15', |
| 77 | + '$count' => 'true', |
| 78 | + ]); |
| 79 | +}); |
| 80 | + |
| 81 | +test('getParams forces count to be true when missing', function () { |
| 82 | + $contacts = new Contacts(); |
| 83 | + $reflection = new ReflectionMethod(Contacts::class, 'getParams'); |
| 84 | + $response = $reflection->invoke($contacts, ['$top' => 10, '$skip' => 5], 25); |
| 85 | + |
| 86 | + parse_str($response, $parsedParams); |
| 87 | + |
| 88 | + expect($parsedParams)->toMatchArray([ |
| 89 | + '$top' => '10', |
| 90 | + '$skip' => '5', |
| 91 | + '$count' => 'true', |
| 92 | + ]); |
| 93 | +}); |
| 94 | + |
37 | 95 | test('find method retrieves a specific contact', function () { |
38 | 96 |
|
39 | 97 | MsGraph::shouldReceive('get') |
|
0 commit comments