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

RegistryTest::testConstruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
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