1 | <?php |
||||||
2 | |||||||
3 | namespace Dynamic\Salsify\Tests\Model\ORM; |
||||||
4 | |||||||
5 | use Dynamic\Salsify\ORM\SalsifyIDExtension; |
||||||
6 | use Dynamic\Salsify\Tests\TestOnly\MappedObject; |
||||||
7 | use Dynamic\Salsify\Tests\TestOnly\TestController; |
||||||
8 | use SilverStripe\CMS\Forms\SiteTreeURLSegmentField; |
||||||
0 ignored issues
–
show
|
|||||||
9 | use SilverStripe\Control\HTTPRequest; |
||||||
10 | use SilverStripe\Control\Session; |
||||||
11 | use SilverStripe\Dev\SapphireTest; |
||||||
12 | use SilverStripe\Forms\FieldList; |
||||||
13 | use SilverStripe\Forms\FormAction; |
||||||
14 | use SilverStripe\Forms\FormField; |
||||||
15 | |||||||
16 | /** |
||||||
17 | * Class SalsifyIDExtensionTest |
||||||
18 | * @package Dynamic\Salsify\Tests\Model\ORM |
||||||
19 | */ |
||||||
20 | class SalsifyIDExtensionTest extends SapphireTest |
||||||
21 | { |
||||||
22 | /** |
||||||
23 | * @var array |
||||||
24 | */ |
||||||
25 | protected static $extra_dataobjects = [ |
||||||
26 | MappedObject::class, |
||||||
27 | ]; |
||||||
28 | |||||||
29 | /** |
||||||
30 | * @var array |
||||||
31 | */ |
||||||
32 | protected static $extra_controllers = [ |
||||||
33 | TestController::class, |
||||||
34 | ]; |
||||||
35 | |||||||
36 | /** |
||||||
37 | * @var array |
||||||
38 | */ |
||||||
39 | protected static $required_extensions = [ |
||||||
40 | MappedObject::class => [ |
||||||
41 | SalsifyIDExtension::class, |
||||||
42 | ], |
||||||
43 | ]; |
||||||
44 | |||||||
45 | /** |
||||||
46 | * |
||||||
47 | */ |
||||||
48 | public function testUpdateCMSFieldsWithID() |
||||||
49 | { |
||||||
50 | /** @var MappedObject|SalsifyIDExtension $object */ |
||||||
51 | $object = MappedObject::create(); |
||||||
52 | $object->SalsifyID = '001'; |
||||||
0 ignored issues
–
show
The property
SalsifyID does not exist on Dynamic\Salsify\Tests\TestOnly\MappedObject . Since you implemented __set , consider adding a @property annotation.
![]() |
|||||||
53 | $fields = $object->getCMSFields(); |
||||||
0 ignored issues
–
show
The method
getCMSFields() does not exist on Dynamic\Salsify\ORM\SalsifyIDExtension .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||||
54 | $this->assertInstanceOf(FieldList::class, $fields); |
||||||
55 | $this->assertInstanceOf(FormField::class, $fields->fieldByName('SalsifyID')); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$fields->fieldByName('SalsifyID') targeting SilverStripe\Forms\FieldList::fieldByName() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
56 | $this->assertEquals(SiteTreeURLSegmentField::class, $fields->fieldByName('SalsifyID')->getTemplate()); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$fields->fieldByName('SalsifyID') targeting SilverStripe\Forms\FieldList::fieldByName() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
57 | } |
||||||
58 | |||||||
59 | /** |
||||||
60 | * |
||||||
61 | */ |
||||||
62 | public function testUpdateCMSFieldsWithoutID() |
||||||
63 | { |
||||||
64 | /** @var MappedObject|SalsifyIDExtension $object */ |
||||||
65 | $object = MappedObject::create(); |
||||||
66 | $fields = $object->getCMSFields(); |
||||||
67 | $this->assertInstanceOf(FieldList::class, $fields); |
||||||
68 | $this->assertInstanceOf(FormField::class, $fields->fieldByName('SalsifyID')); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$fields->fieldByName('SalsifyID') targeting SilverStripe\Forms\FieldList::fieldByName() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
69 | $this->assertNotEquals(SiteTreeURLSegmentField::class, $fields->fieldByName('SalsifyID')); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$fields->fieldByName('SalsifyID') targeting SilverStripe\Forms\FieldList::fieldByName() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
70 | } |
||||||
71 | |||||||
72 | /** |
||||||
73 | * |
||||||
74 | */ |
||||||
75 | public function testUpdateCMSActionsWithoutID() |
||||||
76 | { |
||||||
77 | /** @var MappedObject|SalsifyIDExtension $object */ |
||||||
78 | $object = MappedObject::create(); |
||||||
79 | $actions = $object->getCMSActions(); |
||||||
0 ignored issues
–
show
The method
getCMSActions() does not exist on Dynamic\Salsify\ORM\SalsifyIDExtension .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||||
80 | $this->assertInstanceOf(FieldList::class, $actions); |
||||||
81 | $this->assertNull($actions->fieldByName('action_salsifyFetch')); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$actions->fieldByName('action_salsifyFetch') targeting SilverStripe\Forms\FieldList::fieldByName() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
82 | } |
||||||
83 | |||||||
84 | /** |
||||||
85 | * |
||||||
86 | */ |
||||||
87 | public function testUpdateCMSActionsWithID() |
||||||
88 | { |
||||||
89 | $controller = TestController::create(); |
||||||
90 | $request = new HTTPRequest('GET', '/'); |
||||||
91 | $session = new Session([]); |
||||||
92 | $request->setSession($session); |
||||||
93 | $controller->setRequest($request); |
||||||
94 | $controller->doInit(); |
||||||
95 | $controller->pushCurrent(); |
||||||
96 | |||||||
97 | |||||||
98 | /** @var MappedObject|SalsifyIDExtension $object */ |
||||||
99 | $object = MappedObject::create(); |
||||||
100 | $object->SalsifyID = '001'; |
||||||
0 ignored issues
–
show
The property
SalsifyID does not exist on Dynamic\Salsify\Tests\TestOnly\MappedObject . Since you implemented __set , consider adding a @property annotation.
![]() |
|||||||
101 | $actions = $object->getCMSActions(); |
||||||
102 | $this->assertInstanceOf(FieldList::class, $actions); |
||||||
103 | $this->assertInstanceOf(FormAction::class, $actions->fieldByName('action_salsifyFetch')); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$actions->fieldByName('action_salsifyFetch') targeting SilverStripe\Forms\FieldList::fieldByName() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
104 | } |
||||||
105 | } |
||||||
106 |
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