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

ShoppingCartControllerTest::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
/**
4
 * @link ShoppingCart_Controller
5
 *
6
 * Test manipulating via urls.
7
 */
8
class ShoppingCartControllerTest extends FunctionalTest
9
{
10
    public static $fixture_file   = 'silvershop/tests/fixtures/shop.yml';
11
    public static $disable_theme  = true;
12
    public static $use_draft_site = false;
13
14
    public function setUpOnce()
15
    {
16
        parent::setUpOnce();
17
        // clear session
18
        ShoppingCart::singleton()->clear();
19
    }
20
21
    public function setUp()
22
    {
23
        parent::setUp();
24
25
        ShopTest::setConfiguration(); //reset config
26
27
        $this->mp3player = $this->objFromFixture('Product', 'mp3player');
0 ignored issues
show
Bug introduced by
The property mp3player 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...
28
        $this->socks = $this->objFromFixture('Product', 'socks');
0 ignored issues
show
Bug introduced by
The property socks 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...
29
        //products that can't be purchased
30
        $this->noPurchaseProduct = $this->objFromFixture('Product', 'beachball');
0 ignored issues
show
Bug introduced by
The property noPurchaseProduct 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...
31
        $this->draftProduct = $this->objFromFixture('Product', 'tshirt');
0 ignored issues
show
Bug introduced by
The property draftProduct 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...
32
        $this->noPriceProduct = $this->objFromFixture('Product', 'hdtv');
0 ignored issues
show
Bug introduced by
The property noPriceProduct 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...
33
34
        //publish some products
35
        $this->mp3player->publish('Stage', 'Live');
36
        $this->socks->publish('Stage', 'Live');
37
        $this->noPurchaseProduct->publish('Stage', 'Live');
38
        $this->noPriceProduct->publish('Stage', 'Live');
39
        //note that we don't publish 'tshirt'... we want it to remain in draft form.
40
41
        $this->cart = ShoppingCart::singleton();
0 ignored issues
show
Bug introduced by
The property cart 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...
42
    }
43
44
    public function testAddToCart()
45
    {
46
        // add 2 of the same items via url
47
        $this->get(ShoppingCart_Controller::add_item_link($this->mp3player)); //add item via url
0 ignored issues
show
Security Bug introduced by
It seems like \ShoppingCart_Controller..._link($this->mp3player) targeting ShoppingCart_Controller::add_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
48
        $this->get(ShoppingCart_Controller::add_item_link($this->mp3player)); //add another
0 ignored issues
show
Security Bug introduced by
It seems like \ShoppingCart_Controller..._link($this->mp3player) targeting ShoppingCart_Controller::add_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
49
        $this->get(ShoppingCart_Controller::add_item_link($this->socks)); //add a different product
0 ignored issues
show
Security Bug introduced by
It seems like \ShoppingCart_Controller...item_link($this->socks) targeting ShoppingCart_Controller::add_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
50
        $this->get(
51
            ShoppingCart_Controller::add_item_link($this->noPurchaseProduct)
0 ignored issues
show
Security Bug introduced by
It seems like \ShoppingCart_Controller...his->noPurchaseProduct) targeting ShoppingCart_Controller::add_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
52
        );  //add a product that you can't add
53
        $this->get(ShoppingCart_Controller::add_item_link($this->draftProduct));  //add a product that is draft
0 ignored issues
show
Security Bug introduced by
It seems like \ShoppingCart_Controller...nk($this->draftProduct) targeting ShoppingCart_Controller::add_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
54
        $this->get(ShoppingCart_Controller::add_item_link($this->noPriceProduct));  //add a product that has no price
0 ignored issues
show
Security Bug introduced by
It seems like \ShoppingCart_Controller...($this->noPriceProduct) targeting ShoppingCart_Controller::add_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
55
56
        // See what's in the cart
57
        $items = ShoppingCart::curr()->Items();
0 ignored issues
show
Documentation Bug introduced by
The method Items does not exist on object<Order>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
58
        $this->assertNotNull($items);
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<ShoppingCartControllerTest>.

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...
59
60
        $this->assertEquals($items->Count(), 2, 'There are 2 items in the cart');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartControllerTest>.

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...
61
        //join needed to provide ProductID
62
        $mp3playeritem =
63
            $items->innerJoin("Product_OrderItem", "\"OrderItem\".\"ID\" = \"Product_OrderItem\".\"ID\"")->find(
64
                'ProductID',
65
                $this->mp3player->ID
66
            );    //join needed to provide ProductID
67
        $this->assertNotNull($mp3playeritem, "Mp3 player is in cart");
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<ShoppingCartControllerTest>.

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...
68
69
        // We have the product that we asserted in our fixture file, with a quantity of 2 in the cart
70
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartControllerTest>.

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...
71
            $mp3playeritem->ProductID,
72
            $this->mp3player->ID,
73
            'We have the correct Product ID in the cart.'
74
        );
75
        $this->assertEquals($mp3playeritem->Quantity, 2, 'We have 2 of this product in the cart.');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartControllerTest>.

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...
76
77
        // set item quantiy
78
        $this->get(
79
            ShoppingCart_Controller::set_quantity_item_link($this->mp3player, array('quantity' => 5))
0 ignored issues
show
Security Bug introduced by
It seems like \ShoppingCart_Controller...array('quantity' => 5)) targeting ShoppingCart_Controller::set_quantity_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
80
        ); //add item via url
81
        $items = ShoppingCart::curr()->Items();
0 ignored issues
show
Documentation Bug introduced by
The method Items does not exist on object<Order>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
82
        $mp3playeritem =
83
            $items->innerJoin("Product_OrderItem", "\"OrderItem\".\"ID\" = \"Product_OrderItem\".\"ID\"")->find(
84
                'ProductID',
85
                $this->mp3player->ID
86
            ); //join needed to provide ProductID
87
        $this->assertEquals($mp3playeritem->Quantity, 5, 'We have 5 of this product in the cart.');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartControllerTest>.

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...
88
89
        // non purchasable product checks
90
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartControllerTest>.

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...
91
            $this->noPurchaseProduct->canPurchase(),
92
            false,
93
            'non-purcahseable product is not purchaseable'
94
        );
95
        $this->assertArrayNotHasKey(
0 ignored issues
show
Bug introduced by
The method assertArrayNotHasKey() does not seem to exist on object<ShoppingCartControllerTest>.

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...
96
            $this->noPurchaseProduct->ID,
97
            $items->map('ProductID')->toArray(),
98
            'non-purcahable product is not in cart'
99
        );
100
        $this->assertEquals($this->draftProduct->canPurchase(), true, 'draft products can be purchased');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartControllerTest>.

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...
101
        $this->assertArrayNotHasKey(
0 ignored issues
show
Bug introduced by
The method assertArrayNotHasKey() does not seem to exist on object<ShoppingCartControllerTest>.

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...
102
            $this->draftProduct->ID,
103
            $items->map('ProductID')->toArray(),
104
            'draft product is not in cart'
105
        );
106
        $this->assertEquals($this->noPriceProduct->canPurchase(), false, 'product without price is not purchaseable');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartControllerTest>.

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...
107
        $this->assertArrayNotHasKey(
0 ignored issues
show
Bug introduced by
The method assertArrayNotHasKey() does not seem to exist on object<ShoppingCartControllerTest>.

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...
108
            $this->noPriceProduct->ID,
109
            $items->map('ProductID')->toArray(),
110
            'product without price is not in cart'
111
        );
112
113
        $this->cart->clear();
114
    }
115
116
    public function testRemoveFromCart()
117
    {
118
119
        // add items via url
120
        $this->get(ShoppingCart_Controller::set_quantity_item_link($this->mp3player, array('quantity' => 5)));
0 ignored issues
show
Security Bug introduced by
It seems like \ShoppingCart_Controller...array('quantity' => 5)) targeting ShoppingCart_Controller::set_quantity_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
121
        $this->assertTrue($this->cart->get($this->mp3player) !== false, "mp3player item now exists in cart");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartControllerTest>.

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...
122
        $this->get(ShoppingCart_Controller::add_item_link($this->socks));
0 ignored issues
show
Security Bug introduced by
It seems like \ShoppingCart_Controller...item_link($this->socks) targeting ShoppingCart_Controller::add_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
123
        $this->assertTrue($this->cart->get($this->socks) !== false, "socks item now exists in cart");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartControllerTest>.

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...
124
125
        // remove items via url
126
        $this->get(ShoppingCart_Controller::remove_item_link($this->socks)); //remove one different = remove completely
0 ignored issues
show
Security Bug introduced by
It seems like \ShoppingCart_Controller...item_link($this->socks) targeting ShoppingCart_Controller::remove_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
127
        $this->assertFalse($this->cart->get($this->socks));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ShoppingCartControllerTest>.

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...
128
129
        $this->get(ShoppingCart_Controller::remove_item_link($this->mp3player)); //remove one product = 4 left
0 ignored issues
show
Security Bug introduced by
It seems like \ShoppingCart_Controller..._link($this->mp3player) targeting ShoppingCart_Controller::remove_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
130
131
        $mp3playeritem = $this->cart->get($this->mp3player);
132
        $this->assertTrue($mp3playeritem !== false, "product still exists");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartControllerTest>.

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...
133
        $this->assertEquals($mp3playeritem->Quantity, 4, "only 4 of item left");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartControllerTest>.

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...
134
135
        $items = ShoppingCart::curr()->Items();
0 ignored issues
show
Documentation Bug introduced by
The method Items does not exist on object<Order>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
136
        $this->assertNotNull($items, "Cart is not empty");
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<ShoppingCartControllerTest>.

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...
137
138
        $this->cart->clear(); //test clearing cart
139
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartControllerTest>.

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...
140
            ShoppingCart::curr(),
141
            null,
142
            'Cart is clear'
143
        ); //items is a databoject set, and will therefore be null when cart is empty.
144
    }
145
146
    public function testVariations()
147
    {
148
        $this->loadFixture('silvershop/tests/fixtures/variations.yml');
149
        $ballRoot = $this->objFromFixture('Product', 'ball');
150
        $ballRoot->publish('Stage', 'Live');
151
        $ball1 = $this->objFromFixture('ProductVariation', 'redlarge');
152
        $ball2 = $this->objFromFixture('ProductVariation', 'redsmall');
153
154
        // Add the two variation items
155
        $this->get(ShoppingCart_Controller::add_item_link($ball1));
0 ignored issues
show
Documentation introduced by
$ball1 is of type object<DataObject>|null, but the function expects a object<Buyable>.

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...
Security Bug introduced by
It seems like \ShoppingCart_Controller::add_item_link($ball1) targeting ShoppingCart_Controller::add_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
156
        $this->get(ShoppingCart_Controller::add_item_link($ball2));
0 ignored issues
show
Documentation introduced by
$ball2 is of type object<DataObject>|null, but the function expects a object<Buyable>.

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...
Security Bug introduced by
It seems like \ShoppingCart_Controller::add_item_link($ball2) targeting ShoppingCart_Controller::add_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
157
        $items = ShoppingCart::curr()->Items();
0 ignored issues
show
Documentation Bug introduced by
The method Items does not exist on object<Order>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
158
        $this->assertNotNull($items);
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<ShoppingCartControllerTest>.

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...
159
        $this->assertEquals($items->Count(), 2, 'There are 2 items in the cart');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartControllerTest>.

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...
160
161
        // Remove one and see what happens
162
        $this->get(ShoppingCart_Controller::remove_all_item_link($ball1));
0 ignored issues
show
Documentation introduced by
$ball1 is of type object<DataObject>|null, but the function expects a object<Buyable>.

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...
Security Bug introduced by
It seems like \ShoppingCart_Controller...e_all_item_link($ball1) targeting ShoppingCart_Controller::remove_all_item_link() can also be of type false; however, FunctionalTest::get() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
163
        $this->assertEquals($items->Count(), 1, 'There is 1 item in the cart');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartControllerTest>.

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...
164
        $this->assertFalse($this->cart->get($ball1), "first item not in cart");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ShoppingCartControllerTest>.

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...
165
        $this->assertNotNull($this->cart->get($ball1), "second item is in cart");
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<ShoppingCartControllerTest>.

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...
166
    }
167
}
168