1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dynamic\Foxy\Inventory\Test\Extension; |
4
|
|
|
|
5
|
|
|
use Dynamic\Foxy\Extension\Purchasable; |
6
|
|
|
use Dynamic\Foxy\Extension\PurchasableExtension; |
7
|
|
|
use Dynamic\Foxy\Form\AddToCartForm; |
8
|
|
|
use Dynamic\Foxy\Inventory\Extension\AddToCartFormExtension; |
9
|
|
|
use Dynamic\Foxy\Inventory\Extension\ProductExpirationManager; |
10
|
|
|
use Dynamic\Foxy\Inventory\Extension\ProductInventoryManager; |
11
|
|
|
use Dynamic\Foxy\Inventory\Test\TestOnly\Extension\TestVariationDataExtension; |
12
|
|
|
use Dynamic\Foxy\Inventory\Test\TestOnly\Page\TestProduct; |
13
|
|
|
use Dynamic\Foxy\Inventory\Test\TestOnly\Page\TestProductController; |
14
|
|
|
use Dynamic\Foxy\Model\Variation; |
15
|
|
|
use SilverStripe\Dev\SapphireTest; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class AddToCartFormExtensionTest |
19
|
|
|
* @package Dynamic\Foxy\Inventory\Test\Extension |
20
|
|
|
*/ |
21
|
|
|
class AddToCartFormExtensionTest extends SapphireTest |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
protected static $fixture_file = [ |
27
|
|
|
'../products.yml', |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var array |
32
|
|
|
*/ |
33
|
|
|
protected static $extra_dataobjects = [ |
34
|
|
|
TestProduct::class, |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var array |
39
|
|
|
*/ |
40
|
|
|
protected static $extra_controllers = [ |
41
|
|
|
TestProductController::class, |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var array |
46
|
|
|
*/ |
47
|
|
|
protected static $required_extensions = [ |
48
|
|
|
Variation::class => [ |
49
|
|
|
TestVariationDataExtension::class, |
50
|
|
|
], |
51
|
|
|
AddToCartForm::class => [ |
52
|
|
|
AddToCartFormExtension::class, |
53
|
|
|
], |
54
|
|
|
TestProduct::class => [ |
55
|
|
|
Purchasable::class, |
56
|
|
|
ProductInventoryManager::class, |
57
|
|
|
ProductExpirationManager::class, |
58
|
|
|
], |
59
|
|
|
TestProductController::class => [ |
60
|
|
|
PurchasableExtension::class, |
61
|
|
|
], |
62
|
|
|
]; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* |
66
|
|
|
*/ |
67
|
|
|
public function testUpdateProductFields() |
68
|
|
|
{ |
69
|
|
|
$object = $this->objFromFixture(TestProduct::class, 'productone'); |
70
|
|
|
$controller = TestProductController::create($object); |
71
|
|
|
$form = AddToCartForm::create($controller, __FUNCTION__, null, null, null, $controller->data()); |
72
|
|
|
$fields = $form->Fields(); |
73
|
|
|
|
74
|
|
|
$this->assertNull($fields->dataFieldByName('expires')); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* |
79
|
|
|
*/ |
80
|
|
|
public function testIsOutOfStock() |
81
|
|
|
{ |
82
|
|
|
$this->markTestSkipped(); |
83
|
|
|
// todo: write test to test out of stock via fixtures |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|