Completed
Push — master ( ebe931...c89697 )
by GBProd
02:12
created

RegistryEntryTest::testMatch()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 28
rs 8.8571
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
3
namespace Tests\GBProd\ElasticsearchDataProviderBundle\DataProvider;
4
5
use GBProd\ElasticsearchDataProviderBundle\DataProvider\RegistryEntry;
6
use GBProd\ElasticsearchDataProviderBundle\DataProvider\DataProviderInterface;
7
8
/**
9
 * Tests for DataProvider registry entry
10
 * 
11
 * @author gbprod <[email protected]>
12
 */
13
class RegistryEntryTest extends \PHPUnit_Framework_TestCase
14
{
15
    public function testGetProvidersEmptyIfNoProviders()
16
    {
17
        $provider = $this->getMock(DataProviderInterface::class);
18
        
19
        $testedInstance = new RegistryEntry(
20
            $provider,
21
            'my_index',
22
            'my_type'
23
        );
24
        
25
        $this->assertEquals(
26
            $provider, 
27
            $testedInstance->getProvider()
28
        );
29
        
30
        $this->assertEquals(
31
            'my_index', 
32
            $testedInstance->getIndex()
33
        );
34
        $this->assertEquals(
35
            'my_type', 
36
            $testedInstance->getType()
37
        );
38
    }
39
    
40
    public function testMatch()
41
    {
42
       $testedInstance = new RegistryEntry(
43
            $this->getMock(DataProviderInterface::class),
44
            'my_index',
45
            'my_type'
46
        );
47
        
48
        $this->assertTrue(
49
            $testedInstance->match('my_index', 'my_type')
50
        );
51
        
52
        $this->assertFalse(
53
            $testedInstance->match('my_index', 'my_type_2')
54
        );
55
        
56
        $this->assertTrue(
57
            $testedInstance->match('my_index', null)
58
        );
59
        
60
        $this->assertFalse(
61
            $testedInstance->match('my_index_2', 'my_type')
62
        );
63
        
64
        $this->assertTrue(
65
            $testedInstance->match(null, null)
66
        );
67
    }
68
}
69