Completed
Push — develop ( 0a2cdf...062ac6 )
by Bartko
03:22
created

NestedSetTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testFactoryMethod() 0 10 1
A testThrowExceptionIfYouDbAdapterIsNotSupporter() 0 10 1
A factoryDataProvider() 0 17 1
1
<?php
2
namespace StefanoTreeTest\Unit;
3
4
use StefanoTree\NestedSet;
5
6
class NestedSetTest
7
    extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
8
{
9
    public function factoryDataProvider()
10
    {
11
        return array(
12
            array(
13
                '\Zend\Db\Adapter\Adapter',
14
                '\StefanoTree\NestedSet\Adapter\Zend2',
15
            ),
16
            array(
17
                '\Doctrine\DBAL\Connection',
18
                '\StefanoTree\NestedSet\Adapter\Doctrine2DBAL',
19
            ),
20
//            array( // todo
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
21
//                '\Zend_Db_Adapter_Abstract',
22
//                '\StefanoTree\NestedSet\Adapter\Zend1DbAdapter',
23
//            ),
24
        );
25
    }
26
27
    /**
28
     * @dataProvider factoryDataProvider
29
     */
30
    public function testFactoryMethod($dbAdapterClass, $expectedAdapterClass)
31
    {
32
        $optionsStub = \Mockery::mock('\StefanoTree\NestedSet\Options');
33
        $dbAdapterStub = \Mockery::mock($dbAdapterClass);
34
35
        $tree = NestedSet::factory($optionsStub, $dbAdapterStub);
36
        $adapter = $tree->getAdapter();
37
38
        $this->assertInstanceOf($expectedAdapterClass, $adapter);
39
    }
40
41
    public function testThrowExceptionIfYouDbAdapterIsNotSupporter()
42
    {
43
        $optionsStub = \Mockery::mock('\StefanoTree\NestedSet\Options');
44
        $dbAdapter = new \DateTime();
45
46
        $this->setExpectedException('\StefanoTree\Exception\InvalidArgumentException',
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
47
            'Db adapter "DateTime" is not supported');
48
49
        NestedSet::factory($optionsStub, $dbAdapter);
50
    }
51
}
52