Completed
Pull Request — master (#557)
by Roman
41:00 queued 10:48
created

ShoppingCartTest::testCartSingleton()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
class ShoppingCartTest extends SapphireTest
4
{
5
    public static $fixture_file   = 'silvershop/tests/fixtures/shop.yml';
6
    public static $disable_theme  = true;
7
    public static $use_draft_site = false;
8
9
    public function setUp()
10
    {
11
        parent::setUp();
12
        ShopTest::setConfiguration(); //reset config
13
        Config::inst()->update('Order', 'extensions', ['ShoppingCartTest_TestShoppingCartHooksExtension']);
14
15
        ShoppingCart::singleton()->clear();
16
        ShoppingCartTest_TestShoppingCartHooksExtension::reset();
17
        $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...
18
        $this->product = $this->objFromFixture('Product', 'mp3player');
0 ignored issues
show
Bug introduced by
The property product 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...
19
        $this->product->publish('Stage', 'Live');
20
    }
21
22
    public function testAddToCart()
23
    {
24
        $this->assertTrue((boolean)$this->cart->add($this->product), "add one item");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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

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...
26
            ['onStartOrder', 'beforeAdd', 'afterAdd'],
27
            ShoppingCartTest_TestShoppingCartHooksExtension::$stack
28
        );
29
30
        $this->assertTrue((boolean)$this->cart->add($this->product), "add another item");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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

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...
32
            ['onStartOrder', 'beforeAdd', 'afterAdd', 'beforeAdd', 'afterAdd'],
33
            ShoppingCartTest_TestShoppingCartHooksExtension::$stack
34
        );
35
36
        $item = $this->cart->get($this->product);
37
        $this->assertEquals($item->Quantity, 2, "quantity is 2");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartTest>.

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...
38
    }
39
40
    public function testRemoveFromCart()
41
    {
42
        $this->assertTrue((boolean)$this->cart->add($this->product), "add item");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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

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...
44
            ['onStartOrder', 'beforeAdd', 'afterAdd'],
45
            ShoppingCartTest_TestShoppingCartHooksExtension::$stack
46
        );
47
48
        $this->assertTrue($this->cart->remove($this->product), "item was removed");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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

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...
50
            ['onStartOrder', 'beforeAdd', 'afterAdd', 'beforeRemove', 'afterRemove'],
51
            ShoppingCartTest_TestShoppingCartHooksExtension::$stack
52
        );
53
        $item = $this->cart->get($this->product);
54
        $this->assertFalse($item, "item not in cart");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ShoppingCartTest>.

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...
55
        $this->assertFalse($this->cart->remove($this->product), "try remove non-existent item");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ShoppingCartTest>.

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...
56
    }
57
58
    public function testSetQuantity()
59
    {
60
        $this->assertTrue((boolean)$this->cart->setQuantity($this->product, 25), "quantity set");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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

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...
63
            ['onStartOrder', 'beforeSetQuantity', 'afterSetQuantity'],
64
            ShoppingCartTest_TestShoppingCartHooksExtension::$stack
65
        );
66
67
        $item = $this->cart->get($this->product);
68
        $this->assertEquals($item->Quantity, 25, "quantity is 25");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartTest>.

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...
69
70
    }
71
72
    public function testClear()
73
    {
74
        //$this->assertFalse($this->cart->current(),"there is no cart initally");
75
        $this->assertTrue((boolean)$this->cart->add($this->product), "add one item");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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
        $this->assertTrue((boolean)$this->cart->add($this->product), "add another item");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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...
77
        $this->assertEquals($this->cart->current()->class, "Order", "there a cart");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartTest>.

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...
78
        $this->assertTrue($this->cart->clear(), "clear the cart");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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...
79
        $this->assertFalse($this->cart->current(), "there is no cart");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ShoppingCartTest>.

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...
80
    }
81
82
    public function testProductVariations()
83
    {
84
        $this->loadFixture('silvershop/tests/fixtures/variations.yml');
85
        $ball1 = $this->objFromFixture('ProductVariation', 'redlarge');
86
        $ball2 = $this->objFromFixture('ProductVariation', 'redsmall');
87
88
        $this->assertTrue((boolean)$this->cart->add($ball1), "add one item");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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

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
            ['onStartOrder', 'beforeAdd', 'afterAdd'],
92
            ShoppingCartTest_TestShoppingCartHooksExtension::$stack
93
        );
94
95
        $this->assertTrue((boolean)$this->cart->add($ball2), "add another item");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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

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

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...
99
            ['onStartOrder', 'beforeAdd', 'afterAdd', 'beforeAdd', 'afterAdd', 'beforeRemove', 'afterRemove'],
100
            ShoppingCartTest_TestShoppingCartHooksExtension::$stack
101
        );
102
103
        $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<ShoppingCartTest>.

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...
104
        $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<ShoppingCartTest>.

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...
105
    }
106
107
    public function testCartSingleton()
108
    {
109
        $this->assertTrue((boolean)$this->cart->add($this->product), "add one item");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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...
110
        $order = $this->cart->current();
111
112
        $this->assertEquals($order->ID, ShoppingCart::curr()->ID, "if singleton order ids will match");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartTest>.

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...
113
    }
114
115
    public function testAddProductWithVariations()
116
    {
117
        $this->loadFixture('silvershop/tests/fixtures/variations.yml');
118
        $ball = $this->objFromFixture('Product', 'ball');
119
        $redlarge = $this->objFromFixture('ProductVariation', 'redlarge');
120
        // setting price of variation to zero, so it can't be added to cart.
121
        $redlarge->Price = 0;
122
        $redlarge->write();
123
124
        $ball->BasePrice = 0;
125
        $ball->write();
126
127
        $item = $this->cart->add($ball);
128
        $this->assertNotNull($item, "Product with variations can be added to cart");
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<ShoppingCartTest>.

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...
129
        $this->assertInstanceOf('ProductVariation_OrderItem', $item, 'A variation should be added to cart.');
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<ShoppingCartTest>.

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...
130
        $this->assertEquals(20, $item->Buyable()->Price, 'The buyable variation was added');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartTest>.

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...
131
    }
132
133
    public function testErrorInCartHooks()
134
    {
135
        Config::inst()->update('Order', 'extensions', ['ShoppingCartTest_TestShoppingCartErroringHooksExtension']);
136
137
        ShoppingCart::singleton()->clear();
138
        $cart = ShoppingCart::singleton();
139
140
        $this->assertTrue((boolean)$this->cart->add($this->product, 1), "add one item");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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...
141
        $item = $cart->get($this->product);
142
        $this->assertFalse(
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ShoppingCartTest>.

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...
143
            (boolean)$this->cart->add($this->product, 1),
144
            "Cannot add more than one item, extension will error"
145
        );
146
        $this->assertEquals($item->Quantity, 1, "quantity is 1");
0 ignored issues
show
Documentation introduced by
The property Quantity does not exist on object<OrderItem>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartTest>.

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...
147
148
        $this->assertTrue((boolean)$cart->setQuantity($this->product, 10), "quantity set");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ShoppingCartTest>.

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...
149
        $item = $cart->get($this->product);
150
        $this->assertEquals($item->Quantity, 10, "quantity is 10");
0 ignored issues
show
Documentation introduced by
The property Quantity does not exist on object<OrderItem>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartTest>.

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...
151
152
        $this->assertFalse((boolean)$cart->setQuantity($this->product, 11), "Cannot set quantity to more than 10 items");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ShoppingCartTest>.

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...
153
        $item = $cart->get($this->product);
154
        $this->assertEquals($item->Quantity, 10, "quantity is 10");
0 ignored issues
show
Documentation introduced by
The property Quantity does not exist on object<OrderItem>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The method assertEquals() does not seem to exist on object<ShoppingCartTest>.

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...
155
    }
156
}
157
158
class ShoppingCartTest_TestShoppingCartHooksExtension extends Extension implements TestOnly
159
{
160
    public static $stack = [];
161
162
    public static function reset()
163
    {
164
        self::$stack = [];
165
    }
166
167
    public function onStartOrder()
168
    {
169
        self::$stack[] = 'onStartOrder';
170
    }
171
172
    public function beforeAdd($buyable, $quantity, $filter)
0 ignored issues
show
Unused Code introduced by
The parameter $buyable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $quantity is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
173
    {
174
        self::$stack[] = 'beforeAdd';
175
    }
176
177
    public function afterAdd($item, $buyable, $quantity, $filter)
0 ignored issues
show
Unused Code introduced by
The parameter $item is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $buyable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $quantity is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
178
    {
179
        self::$stack[] = 'afterAdd';
180
    }
181
182
    public function beforeRemove($buyable, $quantity, $filter)
0 ignored issues
show
Unused Code introduced by
The parameter $buyable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $quantity is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
183
    {
184
        self::$stack[] = 'beforeRemove';
185
    }
186
187
    public function afterRemove($buyable, $quantity, $filter)
0 ignored issues
show
Unused Code introduced by
The parameter $buyable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $quantity is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
188
    {
189
        self::$stack[] = 'afterRemove';
190
    }
191
192
    public function beforeSetQuantity($buyable, $quantity, $filter)
0 ignored issues
show
Unused Code introduced by
The parameter $buyable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $quantity is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
193
    {
194
        self::$stack[] = 'beforeSetQuantity';
195
    }
196
197
    public function afterSetQuantity($item, $buyable, $quantity, $filter)
0 ignored issues
show
Unused Code introduced by
The parameter $item is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $buyable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $quantity is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
198
    {
199
        self::$stack[] = 'afterSetQuantity';
200
    }
201
}
202
203
class ShoppingCartTest_TestShoppingCartErroringHooksExtension extends Extension implements TestOnly
204
{
205
    public function beforeSetQuantity($buyable, $quantity, $filter)
0 ignored issues
show
Unused Code introduced by
The parameter $buyable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
206
    {
207
        if($quantity > 10) {
208
            throw new Exception('Invalid quantity');
209
        }
210
    }
211
212
    public function afterAdd($item, $buyable, $quantity, $filter)
0 ignored issues
show
Unused Code introduced by
The parameter $buyable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $quantity is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
213
    {
214
        if($item->Quantity > 1) {
215
            throw new Exception('Invalid quantity');
216
        }
217
    }
218
}
219
220