|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dynamic\Salsify\Tests\Model\Mapper; |
|
4
|
|
|
|
|
5
|
|
|
use Dyanmic\Salsify\ORM\SalsifyIDExtension; |
|
6
|
|
|
use Dynamic\Salsify\Tests\TestOnly\MappedObject; |
|
7
|
|
|
use Dynamic\Salsify\Tests\TestOnly\TestController; |
|
|
|
|
|
|
8
|
|
|
use SilverStripe\Control\HTTPRequest; |
|
9
|
|
|
use SilverStripe\Control\Session; |
|
10
|
|
|
use SilverStripe\Dev\SapphireTest; |
|
11
|
|
|
use SilverStripe\Forms\FieldList; |
|
12
|
|
|
use SilverStripe\Forms\FormAction; |
|
13
|
|
|
use SilverStripe\Forms\FormField; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class MapperTest |
|
17
|
|
|
* @package Dynamic\Salsify\Tests\Model\Mapper |
|
18
|
|
|
*/ |
|
19
|
|
|
class SalsifyIDExtensionTest extends SapphireTest |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var array |
|
23
|
|
|
*/ |
|
24
|
|
|
protected static $extra_dataobjects = [ |
|
25
|
|
|
MappedObject::class, |
|
26
|
|
|
]; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var array |
|
30
|
|
|
*/ |
|
31
|
|
|
protected static $extra_controllers = [ |
|
32
|
|
|
TestController::class, |
|
33
|
|
|
]; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var array |
|
37
|
|
|
*/ |
|
38
|
|
|
protected static $required_extensions = [ |
|
39
|
|
|
MappedObject::class => [ |
|
40
|
|
|
SalsifyIDExtension::class, |
|
41
|
|
|
], |
|
42
|
|
|
]; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* |
|
46
|
|
|
*/ |
|
47
|
|
|
public function testUpdateCMSFieldsWithID() |
|
48
|
|
|
{ |
|
49
|
|
|
/** @var MappedObject|SalsifyIDExtension $object */ |
|
50
|
|
|
$object = MappedObject::create(); |
|
51
|
|
|
$object->SalsifyID = '001'; |
|
|
|
|
|
|
52
|
|
|
$fields = $object->getCMSFields(); |
|
|
|
|
|
|
53
|
|
|
$this->assertInstanceOf(FieldList::class, $fields); |
|
54
|
|
|
$this->assertInstanceOf(FormField::class, $fields->fieldByName('SalsifyID')); |
|
55
|
|
|
$this->assertTrue($fields->fieldByName('SalsifyID')->isReadonly()); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* |
|
60
|
|
|
*/ |
|
61
|
|
|
public function testUpdateCMSFieldsWithoutID() |
|
62
|
|
|
{ |
|
63
|
|
|
/** @var MappedObject|SalsifyIDExtension $object */ |
|
64
|
|
|
$object = MappedObject::create(); |
|
65
|
|
|
$fields = $object->getCMSFields(); |
|
66
|
|
|
$this->assertInstanceOf(FieldList::class, $fields); |
|
67
|
|
|
$this->assertInstanceOf(FormField::class, $fields->fieldByName('SalsifyID')); |
|
68
|
|
|
$this->assertFalse($fields->fieldByName('SalsifyID')->isReadonly()); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* |
|
73
|
|
|
*/ |
|
74
|
|
|
public function testUpdateCMSActionsWithoutID() |
|
75
|
|
|
{ |
|
76
|
|
|
/** @var MappedObject|SalsifyIDExtension $object */ |
|
77
|
|
|
$object = MappedObject::create(); |
|
78
|
|
|
$actions = $object->getCMSActions(); |
|
|
|
|
|
|
79
|
|
|
$this->assertInstanceOf(FieldList::class, $actions); |
|
80
|
|
|
$this->assertNull($actions->fieldByName('action_salsifyFetch')); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* |
|
85
|
|
|
*/ |
|
86
|
|
|
public function testUpdateCMSActionsWithID() |
|
87
|
|
|
{ |
|
88
|
|
|
$controller = TestController::create(); |
|
89
|
|
|
$request = new HTTPRequest('GET', '/'); |
|
90
|
|
|
$session = new Session([]); |
|
91
|
|
|
$request->setSession($session); |
|
92
|
|
|
$controller->setRequest($request); |
|
93
|
|
|
$controller->doInit(); |
|
94
|
|
|
$controller->pushCurrent(); |
|
95
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
/** @var MappedObject|SalsifyIDExtension $object */ |
|
98
|
|
|
$object = MappedObject::create(); |
|
99
|
|
|
$object->SalsifyID = '001'; |
|
|
|
|
|
|
100
|
|
|
$actions = $object->getCMSActions(); |
|
101
|
|
|
$this->assertInstanceOf(FieldList::class, $actions); |
|
102
|
|
|
$this->assertInstanceOf(FormAction::class, $actions->fieldByName('action_salsifyFetch')); |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths