1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ElevenLabs\ApiServiceBundle\Tests\Pagination; |
4
|
|
|
|
5
|
|
|
use ElevenLabs\Api\Definition\ResponseDefinition; |
6
|
|
|
use ElevenLabs\Api\Service\Pagination\Pagination; |
7
|
|
|
use ElevenLabs\Api\Service\Pagination\Provider\PaginationProviderInterface; |
|
|
|
|
8
|
|
|
use ElevenLabs\ApiServiceBundle\Pagination\PaginationProviderChain; |
9
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
10
|
|
|
use Psr\Http\Message\ResponseInterface; |
11
|
|
|
use PHPUnit\Framework\TestCase; |
12
|
|
|
|
13
|
|
|
class PaginationProviderChainTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
/** @test */ |
16
|
|
|
public function itMustNotSupportPaginationBecauseThereAreNotProvider() |
17
|
|
|
{ |
18
|
|
|
/** @var ResponseInterface|MockObject $response */ |
19
|
|
|
$response = $this->createMock(ResponseInterface::class); |
20
|
|
|
|
21
|
|
|
/** @var ResponseDefinition|MockObject $responseDefinition */ |
22
|
|
|
$responseDefinition = $this->getMockBuilder(ResponseDefinition::class)->disableOriginalConstructor()->getMock(); |
23
|
|
|
|
24
|
|
|
$provider = new PaginationProviderChain([]); |
25
|
|
|
$this->assertFalse($provider->supportPagination([], $response, $responseDefinition)); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** @test */ |
29
|
|
|
public function itMustNotSupportPagination() |
30
|
|
|
{ |
31
|
|
|
$providers = []; |
32
|
|
|
for ($i = 0; $i < 1; $i++) { |
33
|
|
|
$provider = $this->createMock(PaginationProviderInterface::class); |
34
|
|
|
$provider->expects($this->once())->method('supportPagination')->willReturn(false); |
35
|
|
|
$providers[] = $provider; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** @var ResponseInterface|MockObject $response */ |
39
|
|
|
$response = $this->createMock(ResponseInterface::class); |
40
|
|
|
|
41
|
|
|
/** @var ResponseDefinition|MockObject $responseDefinition */ |
42
|
|
|
$responseDefinition = $this->getMockBuilder(ResponseDefinition::class)->disableOriginalConstructor()->getMock(); |
43
|
|
|
|
44
|
|
|
$provider = new PaginationProviderChain($providers); |
45
|
|
|
$this->assertFalse($provider->supportPagination([], $response, $responseDefinition)); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** @test */ |
49
|
|
|
public function itMustSupportPagination() |
50
|
|
|
{ |
51
|
|
|
$providers = []; |
52
|
|
|
for ($i = 0; $i < 1; $i++) { |
53
|
|
|
$provider = $this->createMock(PaginationProviderInterface::class); |
54
|
|
|
$provider->expects($this->once())->method('supportPagination')->willReturn(true); |
55
|
|
|
$providers[] = $provider; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** @var ResponseInterface|MockObject $response */ |
59
|
|
|
$response = $this->createMock(ResponseInterface::class); |
60
|
|
|
|
61
|
|
|
/** @var ResponseDefinition|MockObject $responseDefinition */ |
62
|
|
|
$responseDefinition = $this->getMockBuilder(ResponseDefinition::class)->disableOriginalConstructor()->getMock(); |
63
|
|
|
|
64
|
|
|
$provider = new PaginationProviderChain($providers); |
65
|
|
|
$this->assertTrue($provider->supportPagination([], $response, $responseDefinition)); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @test |
70
|
|
|
* |
71
|
|
|
* @expectedException \LogicException |
72
|
|
|
* |
73
|
|
|
* @expectedExceptionMessage No pagination provider available |
74
|
|
|
*/ |
75
|
|
|
public function itMustNotReturnPaginationBecauseThrowException() |
76
|
|
|
{ |
77
|
|
|
$data = []; |
78
|
|
|
/** @var ResponseInterface|MockObject $response */ |
79
|
|
|
$response = $this->createMock(ResponseInterface::class); |
80
|
|
|
|
81
|
|
|
/** @var ResponseDefinition|MockObject $responseDefinition */ |
82
|
|
|
$responseDefinition = $this->getMockBuilder(ResponseDefinition::class)->disableOriginalConstructor()->getMock(); |
83
|
|
|
|
84
|
|
|
$provider = new PaginationProviderChain([]); |
85
|
|
|
$provider->getPagination($data, $response, $responseDefinition); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** @test */ |
89
|
|
|
public function itMustReturnPagination() |
90
|
|
|
{ |
91
|
|
|
$data = []; |
92
|
|
|
$pagination = $this->getMockBuilder(Pagination::class)->disableOriginalConstructor()->getMock(); |
93
|
|
|
|
94
|
|
|
$provider = $this->createMock(PaginationProviderInterface::class); |
95
|
|
|
$provider->expects($this->once())->method('supportPagination')->willReturn(true); |
96
|
|
|
$provider->expects($this->once())->method('getPagination')->willReturn($pagination); |
97
|
|
|
|
98
|
|
|
|
99
|
|
|
/** @var ResponseInterface|MockObject $response */ |
100
|
|
|
$response = $this->createMock(ResponseInterface::class); |
101
|
|
|
|
102
|
|
|
/** @var ResponseDefinition|MockObject $responseDefinition */ |
103
|
|
|
$responseDefinition = $this->getMockBuilder(ResponseDefinition::class)->disableOriginalConstructor()->getMock(); |
104
|
|
|
|
105
|
|
|
$provider = new PaginationProviderChain([$provider]); |
106
|
|
|
$this->assertTrue($provider->supportPagination([], $response, $responseDefinition)); |
107
|
|
|
$provider->getPagination($data, $response, $responseDefinition); |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths