LimeSoda_LiveGuard_Test_Model_ObserverTests   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 66
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A _getObserverInstance() 0 4 1
A _getVarienEventObserverMock() 0 4 1
A testControllerFrontInitBeforeNoConfigExists() 0 5 1
B testControllerFrontInitBefore() 0 32 1
1
<?php
2
/**
3
 * Created by Andreas Penz.
4
 * Date: 24.06.14
5
 * Time: 21:53
6
 */
7
8
class LimeSoda_LiveGuard_Test_Model_ObserverTests
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
    extends EcomDev_PHPUnit_Test_Case_Config
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
10
{
11
12
13
    /**
14
     * @return Mage_Core_Model_Abstract
15
     */
16
    protected function _getObserverInstance()
17
    {
18
        return Mage::getModel('limesoda_liveguard/observer');
19
    }
20
21
    /**
22
     * @return Varien_Event_Observer
23
     */
24
    protected function _getVarienEventObserverMock()
25
    {
26
        return $this->getMock('Varien_Event_Observer');
27
    }
28
29
    /**
30
     * @test
31
     */
32
    public function testControllerFrontInitBeforeNoConfigExists()
33
    {
34
        $observer = $this->_getObserverInstance()->controllerFrontInitBefore($this->_getVarienEventObserverMock());
35
        $this->assertInstanceOf('LimeSoda_LiveGuard_Model_Observer', $observer);
36
    }
37
38
    /**
39
     * @test
40
     */
41
    public function testControllerFrontInitBefore()
42
    {
43
        $mock = $this->getModelMock('limesoda_liveguard/config', array('configExists', 'getGuards'));
44
45
        $mock->expects($this->once())
46
            ->method('configExists')
47
            ->will($this->returnValue(true));
48
49
        $fourthGuardMock = $this->getMock('Fourth_Guard_Class', array('process'));
50
51
        $fourthGuardMock->expects($this->once())
52
            ->method('process');
53
54
        $this->replaceByMock('model', 'fourth_guard/class', $fourthGuardMock);
55
56
        $fifthGuardMock = $this->getMock('Second_Guard_Class');
57
58
        $fifthGuardMock->expects($this->once())
59
            ->method('process');
60
61
        $this->replaceByMock('model', 'second_guard/class', $fifthGuardMock);
62
63
        $mock->expects($this->once())
64
            ->method('getGuards')
65
            ->will($this->returnValue(array( $fourthGuardMock, $fifthGuardMock)));
66
67
        $this->replaceByMock('model', 'limesoda_liveguard/config', $mock);
68
69
        $observer = $this->_getObserverInstance()->controllerFrontInitBefore($this->_getVarienEventObserverMock());
70
71
        $this->assertInstanceOf('LimeSoda_LiveGuard_Model_Observer', $observer);
72
    }
73
}
74
75
class Fourth_Guard_Class
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
76
    implements LimeSoda_LiveGuard_Model_GuardInterface
0 ignored issues
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
77
{
78
    public function process()
79
    {
80
81
    }
82
}
83
84
class Fifth_Guard_Class
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
85
    implements LimeSoda_LiveGuard_Model_GuardInterface
0 ignored issues
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
86
{
87
    public function process()
88
    {
89
90
    }
91
}
92