StockTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 13 1
A testConstruction() 0 4 1
1
<?php
2
require_once 'Intraface/Kernel.php';
3
require_once 'Intraface/DBQuery.php';
4
require_once 'Intraface/modules/stock/Stock.php';
5
require_once 'DB/Sql.php';
6
class FakeStockProduct
7
{
8
    public $kernel;
9
    function __construct($kernel)
10
    {
11
        $this->kernel = $kernel;
12
    }
13
    function get()
14
    {
15
        return 1;
16
    }
17
}
18
19
class StockTest extends PHPUnit_Framework_TestCase
20
{
21
    private $stock;
22
23
    function setUp()
24
    {
25
        $this->kernel = new Stub_Kernel();
0 ignored issues
show
Bug introduced by
The property kernel does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
26
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% 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...
27
        $db = MDB2::singleton(DB_DSN);
28
        $db->query('TRUNCATE product');
29
        $db->query('TRUNCATE product_detail');
30
        $db->query('TRUNCATE product_detail_translation');
31
        */
32
        $product = new FakeStockProduct($this->kernel);
33
34
        $this->stock = new Stock($product);
35
    }
36
37
    function testConstruction()
38
    {
39
        $this->assertTrue(is_object($this->stock));
40
    }
41
}
42