ArraySnapshotTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 0
cbo 1
dl 0
loc 36
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testCompare() 0 5 1
A providerCompare() 0 9 1
A testDeepConstructor() 0 4 1
A deepProvider() 0 6 1
1
<?php
2
/**
3
 * This file is part of the Totem package
4
 *
5
 * For the full copyright and license information, please view the LICENSE file
6
 * that was distributed with this source code.
7
 *
8
 * @copyright Baptiste Clavié <[email protected]>
9
 * @license   http://www.opensource.org/licenses/MIT-License MIT License
10
 */
11
12
namespace Totem\Snapshot;
13
14
use stdClass;
15
use ReflectionMethod;
16
17
use PHPUnit_Framework_TestCase;
18
19
class ArraySnapshotTest extends PHPUnit_Framework_TestCase
20
{
21
    /**
22
     * @dataProvider providerCompare
23
     */
24
    public function testCompare($compare, $expect)
25
    {
26
        $snapshot = new ArraySnapshot([]);
27
        $this->assertSame($expect, $snapshot->isComparable($compare));
28
    }
29
30
    public function providerCompare()
31
    {
32
        $snapshot = $this->getMockBuilder('Totem\\AbstractSnapshot')
33
                         ->disableOriginalConstructor()
34
                         ->getMock();
35
36
        return [[new ArraySnapshot([]), true],
37
                [$snapshot, false]];
38
    }
39
40
    /**
41
     * @dataProvider deepProvider
42
     */
43
    public function testDeepConstructor($value)
44
    {
45
        new ArraySnapshot(['foo' => $value]);
46
    }
47
48
    public function deepProvider()
49
    {
50
        return [[(object) ['bar' => 'baz']],
51
                [['bar' => 'baz']],
52
                ['fubar']];
53
    }
54
}
55
56