Completed
Branch master (7dba2f)
by Alejandro
06:12
created

EmailBuilderFactoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A serviceIsCreated() 0 9 1
A exceptionIsThrownIfConfigIsNotFound() 0 10 1
1
<?php
2
declare(strict_types=1);
3
4
namespace AcMailerTest\Model;
5
6
use AcMailer\Exception\ServiceNotCreatedException;
7
use AcMailer\Model\EmailBuilder;
8
use AcMailer\Model\EmailBuilderFactory;
9
use PHPUnit\Framework\TestCase;
10
use Psr\Container\ContainerInterface;
11
12
class EmailBuilderFactoryTest extends TestCase
13
{
14
    /**
15
     * @var EmailBuilderFactory
16
     */
17
    private $factory;
18
19
    public function setUp()
20
    {
21
        $this->factory = new EmailBuilderFactory();
22
    }
23
24
    /**
25
     * @test
26
     */
27
    public function serviceIsCreated()
28
    {
29
        $container = $this->prophesize(ContainerInterface::class);
30
        $container->has('config')->willReturn(true);
31
        $container->get('config')->willReturn(['acmailer_options' => ['emails' => []]]);
32
33
        $instance = $this->factory->__invoke($container->reveal());
34
        $this->assertInstanceOf(EmailBuilder::class, $instance);
35
    }
36
37
    /**
38
     * @test
39
     */
40
    public function exceptionIsThrownIfConfigIsNotFound()
41
    {
42
        $container = $this->prophesize(ContainerInterface::class);
43
        $container->has('config')->willReturn(false);
44
45
        $this->expectException(ServiceNotCreatedException::class);
46
        $this->expectExceptionMessage('Cannot find a config array in the container');
47
48
        $this->factory->__invoke($container->reveal());
49
    }
50
}
51