Completed
Pull Request — master (#3)
by Harry
05:31
created

OptionalLoggerTraitTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 5
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testCallingLogWithNoLoggerSetWillDoNothing() 0 4 1
A testCallingLogWithALoggerSetWillCallTheLogger() 0 11 1
1
<?php
2
/**
3
 * This file is part of graze/data-file
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/data-file/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/data-file
12
 */
13
14
namespace Graze\DataFile\Test\Unit\Helper;
15
16
use Graze\DataFile\Test\Helper\FakeOptionalLogger;
17
use Graze\DataFile\Test\TestCase;
18
use Mockery as m;
19
use Psr\Log\LoggerInterface;
20
use Psr\Log\LogLevel;
21
22
class OptionalLoggerTraitTest extends TestCase
23
{
24
    /**
25
     * @var FakeOptionalLogger
26
     */
27
    private $logger;
28
29
    public function setUp()
30
    {
31
        $this->logger = new FakeOptionalLogger();
32
    }
33
34
    public function testCallingLogWithNoLoggerSetWillDoNothing()
35
    {
36
        $this->logger->doLog("Some text will not throw an exception or anything");
37
    }
38
39
    public function testCallingLogWithALoggerSetWillCallTheLogger()
40
    {
41
        $logger = m::mock(LoggerInterface::class);
42
        $this->logger->setLogger($logger);
43
44
        $logger->shouldReceive('log')
45
               ->with(LogLevel::INFO, 'Graze\DataFile\Test\Helper\FakeOptionalLogger: some text', [])
46
               ->once();
47
48
        $this->logger->doLog('some text');
49
    }
50
}
51