for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
class ShortlistTest extends FunctionalTest
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.
{
public static $fixture_file = 'fixtures.yml';
public function setUp()
parent::setUp();
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
}
public function tearDown()
SS_Datetime::clear_mock_now();
parent::tearDown();
public function testShortlistCreation()
$shortlists = ShortList::get();
$this->get('shortlist');
$this->assertNotEquals($shortlists->Count(), 0);
public function testAddPageToShortlist() {
$testpage = $this->objFromFixture('Page', 'page1');
$this->get('shortlist/add?id=' . $testpage->ID . '&type=Page&s=' . session_id());
$shortlist = DataObject::get_one('ShortList', array('SessionID' => session_id()));
$this->assertNotEquals($shortlist->ShortListItems()->Count(), 0);
public function testRemovePageFromShortlist() {
$shortlist = $this->objFromFixture('ShortList', 'test');
$shortlist
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.
$myVar
$higher
$this->get('shortlist/remove?id=' . $testpage->ID . '&type=Page&s=' . session_id());
$this->assertEquals($shortlist->ShortListItems()->Count(), 0);
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.