Completed
Pull Request — 2.0 (#461)
by Roman
27:38
created

ViewableCartTest::setUpOnce()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
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 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
class ViewableCartTest extends SapphireTest
4
{
5
    public static $fixture_file  = 'silvershop/tests/fixtures/shop.yml';
6
    public static $disable_theme = true;
7
8
    public function setUpOnce()
9
    {
10
        parent::setUpOnce();
11
        // clear session
12
        ShoppingCart::singleton()->clear();
13
    }
14
15
    function setUp()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
16
    {
17
        parent::setUp();
18
        ShopTest::setConfiguration();
19
        $this->objFromFixture("Product", "socks")->publish("Stage", "Live");
20
    }
21
22
    function testCart()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
23
    {
24
        $cart = $this->objFromFixture("Order", "cart");
25
        ShoppingCart::singleton()->setCurrent($cart);
0 ignored issues
show
Documentation introduced by
$cart is of type object<DataObject>|null, but the function expects a object<Order>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
26
        $page = new Page_Controller();
27
        $this->assertEquals("$8.00", (string)$page->renderWith("CartTestTemplate"));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ViewableCartTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
    }
29
}
30