Completed
Push — master ( 06a343...51380c )
by Simon
02:06
created

ShortlistTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
class ShortlistTest extends FunctionalTest
1 ignored issue
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...
4
{
5
    public static $fixture_file = 'fixtures.yml';
6
7
    public function setUp()
8
    {
9
        parent::setUp();
10
        SS_Datetime::set_mock_now('2013-10-10 20:00:00');
11
    }
12
13
    public function tearDown()
14
    {
15
        SS_Datetime::clear_mock_now();
16
        parent::tearDown();
17
    }
18
19
	public function testShortlistCreation()
20
	{
21
        $shortlists = ShortList::get();
22
23
        $this->get('shortlist');
24
25
        $this->assertNotEquals($shortlists->Count(), 0);
26
    }
27
28
    public function testAddPageToShortlist() {
29
        $testpage = $this->objFromFixture('Page', 'page1');
30
31
        $this->get('shortlist/add?id=' . $testpage->ID . '&type=Page&s=' . session_id());
32
33
        $shortlist = DataObject::get_one('ShortList', array('SessionID' => session_id()));
34
35
        $this->assertNotEquals($shortlist->ShortListItems()->Count(), 0);
36
    }
37
38
    public function testRemovePageFromShortlist() {
39
        $shortlist = $this->objFromFixture('ShortList', 'test');
0 ignored issues
show
Unused Code introduced by
$shortlist is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
40
        $testpage = $this->objFromFixture('Page', 'page1');
41
42
        $this->get('shortlist/add?id=' . $testpage->ID . '&type=Page&s=' . session_id());
43
44
        $shortlist = DataObject::get_one('ShortList', array('SessionID' => session_id()));
45
46
        $this->get('shortlist/remove?id=' . $testpage->ID . '&type=Page&s=' . session_id());
47
48
        $this->assertEquals($shortlist->ShortListItems()->Count(), 0);
49
    }
50
}
51