Completed
Push — master ( a017c2...285708 )
by GBProd
02:17
created

RegistryTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstruct() 0 6 1
A isSatisfiedBy() 0 4 1
A testgetFactoryThrowsOutOfRangeExceptionIfFactoryNotRegistred() 0 8 1
A testgetFactoryReturnsAssociatedFactory() 0 13 1
1
<?php
2
3
namespace Tests\GBProd\AlgoliaSpecification;
4
5
use GBProd\AlgoliaSpecification\QueryFactory\Factory;
6
use GBProd\AlgoliaSpecification\Registry;
7
use GBProd\Specification\Specification;
8
9
/**
10
 * Tests for registry
11
 *
12
 * @author gbprod <[email protected]>
13
 */
14
class RegistryTest extends \PHPUnit_Framework_TestCase implements Specification
15
{
16
    public function testConstruct()
17
    {
18
        $registry = new Registry();
19
20
        $this->assertInstanceOf(Registry::class, $registry);
21
    }
22
23
    public function isSatisfiedBy($candidate)
24
    {
25
        return true;
26
    }
27
28
    public function testgetFactoryThrowsOutOfRangeExceptionIfFactoryNotRegistred()
29
    {
30
        $registry = new Registry();
31
32
        $this->expectException(\OutOfRangeException::class);
33
34
        $registry->getFactory($this);
35
    }
36
37
    public function testgetFactoryReturnsAssociatedFactory()
38
    {
39
        $registry = new Registry();
40
41
        $factory = $this->prophesize(Factory::class)->reveal();
42
43
        $registry->register(self::class, $factory);
44
45
        $this->assertEquals(
46
            $factory,
47
            $registry->getFactory($this)
48
        );
49
    }
50
}
51