testgetFactoryThrowsOutOfRangeExceptionIfFactoryNotRegistred()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
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
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * Tests for registry
12
 *
13
 * @author gbprod <[email protected]>
14
 */
15
class RegistryTest extends TestCase implements Specification
16
{
17
    public function testConstruct()
18
    {
19
        $registry = new Registry();
20
21
        $this->assertInstanceOf(Registry::class, $registry);
22
    }
23
24
    public function isSatisfiedBy($candidate): bool
25
    {
26
        return true;
27
    }
28
29
    public function testgetFactoryThrowsOutOfRangeExceptionIfFactoryNotRegistred()
30
    {
31
        $registry = new Registry();
32
33
        $this->expectException(\OutOfRangeException::class);
34
35
        $registry->getFactory($this);
36
    }
37
38
    public function testgetFactoryReturnsAssociatedFactory()
39
    {
40
        $registry = new Registry();
41
42
        $factory = $this->prophesize(Factory::class)->reveal();
43
44
        $registry->register(self::class, $factory);
45
46
        $this->assertEquals(
47
            $factory,
48
            $registry->getFactory($this)
49
        );
50
    }
51
}
52