|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dynamic\Foxy\Orders\Tests\Factory; |
|
4
|
|
|
|
|
5
|
|
|
use Dynamic\Foxy\Extension\Purchasable; |
|
6
|
|
|
use Dynamic\Foxy\Model\FoxyHelper; |
|
7
|
|
|
use Dynamic\Foxy\Model\Variation; |
|
8
|
|
|
use Dynamic\Foxy\Orders\Model\Order; |
|
9
|
|
|
use Dynamic\Foxy\Orders\Tests\TestOnly\Controller\FoxyDataTestController; |
|
10
|
|
|
use Dynamic\Foxy\Orders\Tests\TestOnly\Extension\TestVariationDataExtension; |
|
11
|
|
|
use Dynamic\Foxy\Orders\Tests\TestOnly\Page\TestProduct; |
|
12
|
|
|
use Dynamic\Foxy\Parser\Controller\FoxyController; |
|
13
|
|
|
use SilverStripe\Control\Director; |
|
14
|
|
|
use SilverStripe\Dev\FunctionalTest; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class OrderFactoryTest |
|
18
|
|
|
* @package Dynamic\Foxy\Orders\Tests\Factory |
|
19
|
|
|
*/ |
|
20
|
|
|
class OrderFactoryTest extends FunctionalTest |
|
21
|
|
|
{ |
|
22
|
|
|
const DUMMY_KEY = 'abc123xzy'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var string[] |
|
26
|
|
|
*/ |
|
27
|
|
|
protected static $fixture_file = [ |
|
28
|
|
|
'../orders.yml', |
|
29
|
|
|
'../orderhistory.yml', |
|
30
|
|
|
'../customers.yml', |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var string[] |
|
35
|
|
|
*/ |
|
36
|
|
|
protected static $extra_dataobjects = [ |
|
37
|
|
|
TestProduct::class, |
|
38
|
|
|
]; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var \string[][] |
|
42
|
|
|
*/ |
|
43
|
|
|
protected static $required_extensions = [ |
|
44
|
|
|
Variation::class => [ |
|
45
|
|
|
TestVariationDataExtension::class, |
|
46
|
|
|
], |
|
47
|
|
|
TestProduct::class => [ |
|
48
|
|
|
Purchasable::class, |
|
49
|
|
|
], |
|
50
|
|
|
]; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var string[] |
|
54
|
|
|
*/ |
|
55
|
|
|
protected static $extra_controllers = [ |
|
56
|
|
|
FoxyDataTestController::class, |
|
57
|
|
|
]; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* |
|
61
|
|
|
*/ |
|
62
|
|
|
protected function setUp() |
|
63
|
|
|
{ |
|
64
|
|
|
Director::config()->merge('rules', ['foxy//$Action/$ID/$Name' => FoxyController::class,]); |
|
65
|
|
|
|
|
66
|
|
|
parent::setUp(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* |
|
71
|
|
|
*/ |
|
72
|
|
|
public function testGetOrder() |
|
73
|
|
|
{ |
|
74
|
|
|
$currentKey = FoxyHelper::config()->get('secret'); |
|
75
|
|
|
FoxyHelper::config()->set('secret', static::DUMMY_KEY); |
|
76
|
|
|
|
|
77
|
|
|
$payLoadResponse = $this->get('/foxytestdata.xml'); |
|
78
|
|
|
$this->post('/foxy', ['FoxyData' => $payLoadResponse->getBody()]); |
|
79
|
|
|
|
|
80
|
|
|
$order = Order::get()->filter('OrderID', 111111222222333333)->first(); |
|
81
|
|
|
|
|
82
|
|
|
$this->assertInstanceOf(Order::class, $order); |
|
83
|
|
|
|
|
84
|
|
|
FoxyHelper::config()->set('secret', $currentKey); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|