Completed
Push — master ( 7a3cb1...e42624 )
by Harry
9s
created

FormatAwareTraitTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 47
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testSetFormat() 0 7 1
A testGetFormatType() 0 10 1
A testGetFormatTypeWillReturnNullWithNoFormatIsSpecified() 0 4 1
A testCloningWillCloneFormat() 0 10 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\Format;
15
16
use Graze\DataFile\Test\Format\FakeFormatAware;
17
use Graze\DataFile\Test\TestCase;
18
use Mockery as m;
19
20
class FormatAwareTraitTest extends TestCase
21
{
22
    /**
23
     * @var FakeFormatAware
24
     */
25
    protected $formatAware;
26
27
    public function setUp()
28
    {
29
        $this->formatAware = new FakeFormatAware();
30
    }
31
32
    public function testSetFormat()
33
    {
34
        $format = m::mock('Graze\DataFile\Format\FormatInterface');
35
        $this->formatAware->setFormat($format);
36
37
        static::assertSame($format, $this->formatAware->getFormat());
38
    }
39
40
    public function testGetFormatType()
41
    {
42
        $format = m::mock('Graze\DataFile\Format\FormatInterface');
43
        $this->formatAware->setFormat($format);
44
45
        $format->shouldReceive('getType')
46
               ->andReturn('test_format');
47
48
        static::assertEquals('test_format', $this->formatAware->getFormatType());
49
    }
50
51
    public function testGetFormatTypeWillReturnNullWithNoFormatIsSpecified()
52
    {
53
        static::assertNull($this->formatAware->getFormatType());
54
    }
55
56
    public function testCloningWillCloneFormat()
57
    {
58
        $format = m::mock('Graze\DataFile\Format\FormatInterface');
59
        $this->formatAware->setFormat($format);
60
61
        $newFormatAware = clone $this->formatAware;
62
63
        static::assertNotSame($this->formatAware, $newFormatAware);
64
        static::assertNotSame($this->formatAware->getFormat(), $newFormatAware->getFormat());
65
    }
66
}
67