Completed
Push — master ( b53e51...1009f9 )
by Alejandro
04:13 queued 38s
created

EmptyResponseImplicitOptionsMiddlewareFactoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A serviceIsCreated() 0 5 1
A responsePrototypeIsEmptyResponse() 0 9 1
1
<?php
2
namespace ShlinkioTest\Shlink\Common\Factory;
3
4
use PHPUnit\Framework\TestCase;
5
use Shlinkio\Shlink\Common\Factory\EmptyResponseImplicitOptionsMiddlewareFactory;
6
use Zend\Diactoros\Response\EmptyResponse;
7
use Zend\Expressive\Middleware\ImplicitOptionsMiddleware;
8
use Zend\ServiceManager\ServiceManager;
9
10
class EmptyResponseImplicitOptionsMiddlewareFactoryTest extends TestCase
11
{
12
    /**
13
     * @var EmptyResponseImplicitOptionsMiddlewareFactory
14
     */
15
    protected $factory;
16
17
    public function setUp()
18
    {
19
        $this->factory = new EmptyResponseImplicitOptionsMiddlewareFactory();
20
    }
21
22
    /**
23
     * @test
24
     */
25
    public function serviceIsCreated()
26
    {
27
        $instance = $this->factory->__invoke(new ServiceManager(), '');
28
        $this->assertInstanceOf(ImplicitOptionsMiddleware::class, $instance);
29
    }
30
31
    /**
32
     * @test
33
     */
34
    public function responsePrototypeIsEmptyResponse()
35
    {
36
        $instance = $this->factory->__invoke(new ServiceManager(), '');
37
38
        $ref = new \ReflectionObject($instance);
39
        $prop = $ref->getProperty('response');
40
        $prop->setAccessible(true);
41
        $this->assertInstanceOf(EmptyResponse::class, $prop->getValue($instance));
42
    }
43
}
44