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

RegistryEntryTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 2
c 1
b 1
f 0
lcom 1
cbo 2
dl 0
loc 56
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testGetProvidersEmptyIfNoProviders() 0 24 1
B testMatch() 0 28 1
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