CDITest::testOverwritePreviousDefinedService()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 10
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 16
rs 9.4285
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