Completed
Push — master ( e2aeec...2e17a9 )
by GBProd
02:10
created

HandlerTest::testHandlerRunEveryProviders()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 24
rs 8.9713
cc 1
eloc 16
nc 1
nop 0
1
<?php
2
3
namespace Tests\GBProd\ElasticsearchDataProviderBundle\DataProvider;
4
5
use GBProd\ElasticsearchDataProviderBundle\DataProvider\Registry;
6
use GBProd\ElasticsearchDataProviderBundle\DataProvider\DataProviderInterface;
7
use GBProd\ElasticsearchDataProviderBundle\DataProvider\Handler;
8
use Elasticsearch\Client;
9
10
/**
11
 * Tests for handler
12
 * 
13
 * @author gbprod <[email protected]>
14
 */
15
class HandlerTest extends \PHPUnit_Framework_TestCase
16
{
17
    public function testHandlerRunEveryProviders()
18
    {
19
        $client = $this
20
            ->getMockBuilder(Client::class)
21
            ->disableOriginalConstructor()
22
            ->getMock()
23
        ;
24
        
25
        $registry = $this->getMock(Registry::class);
26
        $registry
27
            ->expects($this->any())
28
            ->method('getProviders')
29
            ->with('my_index', 'my_type')
30
            ->willReturn([
31
                $this->createProviderExpectingRun($client, 'my_index', 'my_type'),
32
                $this->createProviderExpectingRun($client, 'my_index', 'my_type'),
33
                $this->createProviderExpectingRun($client, 'my_index', 'my_type'),
34
            ])
35
        ;
36
        
37
        $handler = new Handler($registry);
38
        
39
        $handler->handle($client, 'my_index', 'my_type');
40
    }
41
    
42
    private function createProviderExpectingRun($client, $index, $type)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
43
    {
44
        $provider = $this->getMock(DataProviderInterface::class);
45
        
46
        $provider
47
            ->expects($this->once())
48
            ->method('run')
49
            ->with($client, $index, $type)
50
        ;
51
        
52
        return $provider;    
53
    }
54
}