Completed
Push — master ( b39006...2667f3 )
by GBProd
03:38
created

testgetFactoryThrowsOutOfRangeExceptionIfFactoryNotRegistred()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Tests\GBProd\ElasticaSpecification;
4
5
use GBProd\ElasticaSpecification\QueryFactory\Factory;
6
use GBProd\ElasticaSpecification\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