CDITest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testLoadFailesInServiceCreation() 0 11 1
A testOverwritePreviousDefinedService() 0 16 1
1
<?php
2
3
namespace Anax\DI;
4
5
/**
6
 * Testing the Dependency Injector service container.
7
 *
8
 */
9
class CDITest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * Test 
13
     *
14
     * @return void
15
     *
16
     * @expectedException \Exception
17
     */
18
    public function testLoadFailesInServiceCreation()
19
    {
20
        $di = new \Anax\DI\CDI();
21
        $service = 'failsWithException';
22
23
        $di->set($service, function () {
24
            throw new \Exception("Failed creating service.");
25
        });
26
27
        $di->get($service);
28
    }
29
30
31
32
    /**
33
     * Test 
34
     *
35
     * @return void
36
     *
37
     */
38
    public function testOverwritePreviousDefinedService()
39
    {
40
        $di = new \Anax\DI\CDIFactoryDefault();
41
        $service = 'session';
42
43
        $di->set($service, function () {
44
            $session = new \Anax\Session\CSession();
45
            $session->configure(ANAX_APP_PATH . 'config/session.php');
46
            $session->name();
47
            //$session->start();
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% 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...
48
            return $session;
49
        });
50
51
        $session = $di->get($service);
52
        $this->assertInstanceOf('\Anax\Session\CSession', $session);
53
    }
54
}
55