Completed
Push — 2.0 ( 6c824d...3cf5ce )
by Roman
18:14 queued 10s
created

OrderTest_TestStatusChangeExtension::reset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * Order Unit Tests
5
 *
6
 * @link       Order
7
 * @package    shop
8
 * @subpackage tests
9
 */
10
class OrderTest extends SapphireTest
11
{
12
    public static $fixture_file = 'silvershop/tests/fixtures/shop.yml';
13
14
    public function setUp()
15
    {
16
        parent::setUp();
17
        ShopTest::setConfiguration();
18
        $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...
19
        $this->mp3player->publish('Stage', 'Live');
20
        $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...
21
        $this->socks->publish('Stage', 'Live');
22
        $this->beachball = $this->objFromFixture('Product', 'beachball');
0 ignored issues
show
Bug introduced by
The property beachball 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...
23
        $this->beachball->publish('Stage', 'Live');
24
    }
25
26
    public function tearDown()
27
    {
28
        parent::tearDown();
29
        unset($this->mp3player);
30
        unset($this->socks);
31
        unset($this->beachball);
32
    }
33
34
    public function testCMSFields()
35
    {
36
        singleton('Order')->getCMSFields();
37
        $this->markTestIncomplete('assertions!');
0 ignored issues
show
Bug introduced by
The method markTestIncomplete() does not seem to exist on object<OrderTest>.

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 testSearchFields()
41
    {
42
        singleton('Order')->scaffoldSearchFields();
43
        $this->markTestIncomplete('assertions!');
0 ignored issues
show
Bug introduced by
The method markTestIncomplete() does not seem to exist on object<OrderTest>.

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
    }
45
46
    public function testDebug()
47
    {
48
        $order = $this->objFromFixture("Order", "cart");
49
        $order->debug();
50
        $this->markTestIncomplete('assertions!');
0 ignored issues
show
Bug introduced by
The method markTestIncomplete() does not seem to exist on object<OrderTest>.

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...
51
    }
52
53
    public function testOrderItems()
54
    {
55
        $order = $this->objFromFixture("Order", "paid");
56
        $items = $order->Items();
57
        $this->assertNotNull($items);
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<OrderTest>.

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...
58
        $this->assertDOSEquals(
59
            array(
60
                array('ProductID' => $this->mp3player->ID, 'Quantity' => 2, 'CalculatedTotal' => 400),
61
                array('ProductID' => $this->socks->ID, 'Quantity' => 1, 'CalculatedTotal' => 8),
62
            ),
63
            $items
64
        );
65
        $this->assertEquals(3, $items->Quantity(), "Quantity is 3");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
66
        $this->assertTrue($items->Plural(), "There is more than one item");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<OrderTest>.

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...
67
        $this->assertEquals(0.7, $items->Sum('Weight', true), "Total order weight sums correctly", 0.0001);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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
70
    public function testTotals()
71
    {
72
        $order = $this->objFromFixture("Order", "paid");
73
        $this->assertEquals(408, $order->SubTotal(), "Subtotal is correct"); // 200 + 200 + 8
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
74
        $this->assertEquals(408, $order->GrandTotal(), "Grand total is correct");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
75
        $this->assertEquals(200, $order->TotalPaid(), "Outstanding total is correct");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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->assertEquals(208, $order->TotalOutstanding(), "Outstanding total is correct");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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
    }
78
79
    public function testRounding()
80
    {
81
        //create an order with unrounded total
82
        $order = new Order(
83
            array(
84
                'Total'  => 123.257323,
85
                //NOTE: setTotal isn't called here, so un-rounded data *could* get in to the object
86
                'Status' => 'Unpaid',
87
            )
88
        );
89
        $order->Total = 123.257323; //setTotal IS called here
0 ignored issues
show
Documentation introduced by
The property Total does not exist on object<Order>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write 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.");
        }
    }

}

Since the property has write access only, you can use the @property-write 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...
90
        $this->assertEquals(123.26, $order->Total(), "Check total rounds appropriately");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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->assertEquals(123.26, $order->TotalOutstanding(), "Check total outstanding rounds appropriately");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
92
    }
93
94
    public function testPlacedOrderImmutability()
95
    {
96
97
        $order = $this->objFromFixture("Order", "paid");
98
        $processor = OrderProcessor::create($order)->placeOrder();
0 ignored issues
show
Documentation introduced by
$order 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...
Unused Code introduced by
$processor 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...
99
        $this->assertEquals(408, $order->Total(), "check totals");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
100
101
        //make a changes to existing products
102
        $this->mp3player->BasePrice = 100;
103
        $this->mp3player->write();
104
        $this->socks->BasePrice = 20;
105
        $this->socks->write();
106
107
        //total doesn't change
108
        $this->assertEquals(408, $order->Total());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
109
        $this->assertFalse($order->isCart());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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
111
        //item values don't change
112
        $items = $order->Items()
113
            //hack join to make thigns work
114
            ->innerJoin(
115
                "Product_OrderItem",
116
                '"OrderItem"."ID" = "Product_OrderItem"."ID"'
117
            );
118
        $this->assertNotNull($items);
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<OrderTest>.

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...
119
        $this->assertDOSEquals(
120
            array(
121
                array('ProductID' => $this->mp3player->ID, 'Quantity' => 2, 'CalculatedTotal' => 400),
122
                array('ProductID' => $this->socks->ID, 'Quantity' => 1, 'CalculatedTotal' => 8),
123
            ),
124
            $items
125
        );
126
127
        $mp3player = $items->find('ProductID', $this->mp3player->ID);//join needed to provide ProductID
128
        $this->assertNotNull($mp3player, "MP3 player is in order");
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<OrderTest>.

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->assertEquals(200, $mp3player->UnitPrice(), "Unit price remains the same");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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(400, $mp3player->Total(), "Total remains the same");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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
        $socks = $items->find('ProductID', $this->socks->ID);
133
        $this->assertNotNull($socks, "Socks are in order");
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<OrderTest>.

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
        $this->assertEquals(8, $socks->UnitPrice(), "Unit price remains the same");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
135
        $this->assertEquals(8, $socks->Total(), "Total remains the same");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
136
    }
137
138
    public function testCanFunctions()
139
    {
140
        $order = $this->objFromFixture("Order", "cart");
141
        $order->calculate();
142
        $this->assertTrue($order->canPay(), "can pay when order is in cart");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<OrderTest>.

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
        $this->assertFalse($order->canCancel(), "can't cancel when order is in cart");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
144
        $this->assertFalse($order->canDelete(), "never allow deleting orders");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
145
        $this->assertTrue($order->canEdit(), "orders can be edited by anyone");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<OrderTest>.

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...
146
        $this->assertFalse($order->canCreate(), "no body can create orders manually");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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
        $order = $this->objFromFixture("Order", "unpaid");
149
        $this->assertTrue($order->canPay(), "can pay an order that is unpaid");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<OrderTest>.

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...
150
        $this->assertTrue($order->canCancel());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<OrderTest>.

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
        $this->assertFalse($order->canDelete(), "never allow deleting orders");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
152
153
        // Override config
154
        Config::inst()->update('Order', 'cancel_before_payment', false);
155
        $this->assertFalse($order->canCancel());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
156
157
        $order = $this->objFromFixture("Order", "paid");
158
        $this->assertFalse($order->canPay(), "paid order can't be paid for");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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->assertFalse($order->canCancel(), "paid order can't be cancelled");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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
        $this->assertFalse($order->canDelete(), "never allow deleting orders");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
161
162
        Config::inst()->update('Order', 'cancel_before_processing', true);
163
        $this->assertTrue($order->canCancel(), "paid order can be cancelled when expcicitly set via config");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<OrderTest>.

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
165
        $order->Status = 'Processing';
166
        $this->assertFalse($order->canPay(), "Processing order can't be paid for");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
167
        $this->assertFalse($order->canCancel(), "Processing order can't be cancelled");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
168
        $this->assertFalse($order->canDelete(), "never allow deleting orders");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
169
170
        Config::inst()->update('Order', 'cancel_before_sending', true);
171
        $this->assertTrue($order->canCancel(), "Processing order can be cancelled when expcicitly set via config");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<OrderTest>.

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...
172
173
        $order->Status = 'Sent';
174
        $this->assertFalse($order->canPay(), "Sent order can't be paid for");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
175
        $this->assertFalse($order->canCancel(), "Sent order can't be cancelled");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
176
        $this->assertFalse($order->canDelete(), "never allow deleting orders");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
177
178
        Config::inst()->update('Order', 'cancel_after_sending', true);
179
        $this->assertTrue($order->canCancel(), "Sent order can be cancelled when expcicitly set via config");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<OrderTest>.

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...
180
        Config::inst()->update('Order', 'cancel_after_sending', false);
181
182
        $order->Status = 'Complete';
183
        $this->assertFalse($order->canPay(), "Complete order can't be paid for");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
184
        $this->assertFalse($order->canCancel(), "Complete order can't be cancelled");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
185
        $this->assertFalse($order->canDelete(), "never allow deleting orders");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
186
187
        Config::inst()->update('Order', 'cancel_after_sending', true);
188
        $this->assertTrue($order->canCancel(), "Completed order can be cancelled when expcicitly set via config");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<OrderTest>.

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...
189
190
        $order->Status = 'AdminCancelled';
191
        $this->assertFalse($order->canPay(), "Cancelled order can't be paid for");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
192
        $this->assertFalse($order->canCancel(), "Cancelled order can't be cancelled");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
193
        $this->assertFalse($order->canDelete(), "never allow deleting orders");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
194
195
        $order->Status = 'MemberCancelled';
196
        $this->assertFalse($order->canPay(), "Cancelled order can't be paid for");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
197
        $this->assertFalse($order->canCancel(), "Cancelled order can't be cancelled");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
198
        $this->assertFalse($order->canDelete(), "never allow deleting orders");
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OrderTest>.

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...
199
    }
200
201
    public function testDelete()
202
    {
203
        Config::inst()->update('FlatTaxModifier', 'rate', 0.25);
204
        Config::inst()->update('Order', 'modifiers', array('FlatTaxModifier'));
205
206
        $order = Order::create();
207
        $shirt = $this->objFromFixture("Product", "tshirt");
208
        $mp3player = $this->objFromFixture("Product", "mp3player");
209
        $order->Items()->add($shirt->createItem(3));
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...
210
        $order->Items()->add($mp3player->createItem(1));
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...
211
        $order->write();
212
        $order->calculate();
213
214
        $statusLogId = OrderStatusLog::create(array(
215
            'Title' => 'Test status log',
216
            'OrderID' => $order->ID
217
        ))->write();
218
219
        $paymentId = Payment::create(array(
220
            'OrderID' => $order->ID
221
        ))->init('Manual', 343.75, 'NZD')->write();
222
223
224
        $this->assertEquals(4, $order->Items()->Quantity());
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...
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
225
        $this->assertEquals(1, $order->Modifiers()->count());
0 ignored issues
show
Documentation Bug introduced by
The method Modifiers 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...
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
226
        $this->assertEquals(1, $order->OrderStatusLogs()->count());
0 ignored issues
show
Documentation Bug introduced by
The method OrderStatusLogs 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...
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
227
        $this->assertEquals(1, $order->Payments()->count());
0 ignored issues
show
Documentation Bug introduced by
The method Payments 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...
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
228
229
        $itemIds = Product_OrderItem::get()->filter('OrderID', $order->ID)->column('ID');
230
        $modifierIds = OrderModifier::get()->filter('OrderID', $order->ID)->column('ID');
231
232
        $order->delete();
233
234
        // Items should no longer be linked to order
235
        $this->assertEquals(0, $order->Items()->count());
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...
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
236
        $this->assertEquals(0, $order->Modifiers()->count());
0 ignored issues
show
Documentation Bug introduced by
The method Modifiers 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...
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
237
        $this->assertEquals(0, $order->OrderStatusLogs()->count());
0 ignored issues
show
Documentation Bug introduced by
The method OrderStatusLogs 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...
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
238
        $this->assertEquals(0, $order->Payments()->count());
0 ignored issues
show
Documentation Bug introduced by
The method Payments 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...
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
239
240
        // Ensure the order items have been deleted!
241
        $this->assertEquals(0, Product_OrderItem::get()->filter('ID', $itemIds)->count());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
242
        $this->assertEquals(0, OrderModifier::get()->filter('ID', $modifierIds)->count());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
243
        $this->assertEquals(0, OrderStatusLog::get()->filter('ID', $statusLogId)->count());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
244
245
        // Keep the payment… it might be relevant for book keeping
246
        $this->assertEquals(1, Payment::get()->filter('ID', $paymentId)->count());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
247
    }
248
249
    public function testStatusChange()
250
    {
251
        Config::inst()->update('Order', 'extensions', array('OrderTest_TestStatusChangeExtension'));
252
253
        $order = Order::create();
254
        $orderId = $order->write();
255
256
        $order->Status = 'Unpaid';
257
        $order->write();
258
259
        $this->assertEquals(array(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
260
            array('Cart' => 'Unpaid')
261
        ), OrderTest_TestStatusChangeExtension::$stack);
262
263
        OrderTest_TestStatusChangeExtension::reset();
264
265
        $order = Order::get()->byID($orderId);
266
        $order->Status = 'Paid';
267
        $order->write();
268
269
        $this->assertEquals(array(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OrderTest>.

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...
270
            array('Unpaid' => 'Paid')
271
        ), OrderTest_TestStatusChangeExtension::$stack);
272
273
        $this->assertTrue((boolean)$order->Paid, 'Order paid date should be set');
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<OrderTest>.

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...
274
    }
275
}
276
277
class OrderTest_TestStatusChangeExtension extends DataExtension implements TestOnly
278
{
279
    public static $stack = array();
280
281
    public static function reset()
282
    {
283
        self::$stack = array();
284
    }
285
286
    public function onStatusChange($fromStatus, $toStatus)
287
    {
288
        self::$stack[] = array(
289
            $fromStatus => $toStatus
290
        );
291
    }
292
}
293