This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Tests for the workflow engine. |
||
4 | * |
||
5 | * @author [email protected] |
||
6 | * @license BSD License (http://silverstripe.org/bsd-license/) |
||
7 | * @package advancedworkflow |
||
8 | * @subpackage tests |
||
9 | */ |
||
10 | class WorkflowEngineTest extends SapphireTest { |
||
0 ignored issues
–
show
|
|||
11 | |||
12 | public static $fixture_file = 'advancedworkflow/tests/workflowinstancetargets.yml'; |
||
13 | |||
14 | public function testCreateWorkflowInstance() { |
||
15 | |||
16 | $definition = new WorkflowDefinition(); |
||
17 | $definition->Title = "Create Workflow Instance"; |
||
0 ignored issues
–
show
The property
Title does not exist on object<WorkflowDefinition> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
18 | $definition->write(); |
||
19 | |||
20 | $stepOne = new WorkflowAction(); |
||
21 | $stepOne->Title = "Step One"; |
||
0 ignored issues
–
show
The property
Title does not exist on object<WorkflowAction> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
22 | $stepOne->WorkflowDefID = $definition->ID; |
||
0 ignored issues
–
show
The property
WorkflowDefID does not exist on object<WorkflowAction> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
23 | $stepOne->write(); |
||
24 | |||
25 | $stepTwo = new WorkflowAction(); |
||
26 | $stepTwo->Title = "Step Two"; |
||
0 ignored issues
–
show
The property
Title does not exist on object<WorkflowAction> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
27 | $stepTwo->WorkflowDefID = $definition->ID; |
||
0 ignored issues
–
show
The property
WorkflowDefID does not exist on object<WorkflowAction> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
28 | $stepTwo->write(); |
||
29 | |||
30 | $transitionOne = new WorkflowTransition(); |
||
31 | $transitionOne->Title = 'Step One T1'; |
||
0 ignored issues
–
show
The property
Title does not exist on object<WorkflowTransition> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
32 | $transitionOne->ActionID = $stepOne->ID; |
||
0 ignored issues
–
show
The property
ActionID does not exist on object<WorkflowTransition> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
33 | $transitionOne->NextActionID = $stepTwo->ID; |
||
0 ignored issues
–
show
The property
NextActionID does not exist on object<WorkflowTransition> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
34 | $transitionOne->write(); |
||
35 | |||
36 | $instance = new WorkflowInstance(); |
||
37 | $instance->write(); |
||
38 | |||
39 | $instance->beginWorkflow($definition); |
||
40 | |||
41 | $actions = $definition->Actions(); |
||
0 ignored issues
–
show
The method
Actions() does not exist on WorkflowDefinition . Did you maybe mean updateAdminActions() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. ![]() |
|||
42 | $this->assertEquals(2, $actions->Count()); |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
43 | |||
44 | $transitions = $actions->find('Title', 'Step One')->Transitions(); |
||
45 | $this->assertEquals(1, $transitions->Count()); |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
46 | } |
||
47 | |||
48 | public function testExecuteImmediateWorkflow() { |
||
49 | $def = $this->createDefinition(); |
||
50 | |||
51 | $actions = $def->Actions(); |
||
0 ignored issues
–
show
The method
Actions() does not exist on WorkflowDefinition . Did you maybe mean updateAdminActions() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. ![]() $actions 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 ![]() |
|||
52 | $firstAction = $def->getInitialAction(); |
||
53 | $this->assertEquals('Step One', $firstAction->Title); |
||
0 ignored issues
–
show
The property
Title does not exist on object<WorkflowAction> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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 | |||
55 | $instance = new WorkflowInstance(); |
||
56 | $instance->beginWorkflow($def); |
||
57 | $this->assertTrue($instance->CurrentActionID > 0); |
||
0 ignored issues
–
show
The property
CurrentActionID does not exist on object<WorkflowInstance> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
58 | |||
59 | $instance->execute(); |
||
60 | |||
61 | // the instance should be complete, and have two finished workflow action |
||
62 | // instances. |
||
63 | $actions = $instance->Actions(); |
||
0 ignored issues
–
show
The method
Actions() does not exist on WorkflowInstance . Did you maybe mean getFrontEndWorkflowActions() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. ![]() |
|||
64 | $this->assertEquals(2, $actions->Count()); |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
65 | |||
66 | foreach($actions as $action) { |
||
67 | $this->assertTrue((bool) $action->Finished); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
68 | } |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Ensure WorkflowInstance returns expected values for a Published target object. |
||
73 | */ |
||
74 | View Code Duplication | public function testInstanceGetTargetPublished() { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
75 | $def = $this->createDefinition(); |
||
76 | $target = $this->objFromFixture('SiteTree', 'published-object'); |
||
77 | $target->doPublish(); |
||
78 | |||
79 | $instance = $this->objFromFixture('WorkflowInstance', 'target-is-published'); |
||
80 | $instance->beginWorkflow($def); |
||
81 | $instance->execute(); |
||
82 | |||
83 | $this->assertTrue($target->isPublished()); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
84 | $this->assertEquals($target->ID, $instance->getTarget()->ID); |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
85 | $this->assertEquals($target->Title, $instance->getTarget()->Title); |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Ensure WorkflowInstance returns expected values for a Draft target object. |
||
90 | */ |
||
91 | View Code Duplication | public function testInstanceGetTargetDraft() { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
92 | $def = $this->createDefinition(); |
||
93 | $target = $this->objFromFixture('SiteTree', 'draft-object'); |
||
94 | |||
95 | $instance = $this->objFromFixture('WorkflowInstance', 'target-is-draft'); |
||
96 | $instance->beginWorkflow($def); |
||
97 | $instance->execute(); |
||
98 | |||
99 | $this->assertFalse($target->isPublished()); |
||
0 ignored issues
–
show
The method
assertFalse() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
100 | $this->assertEquals($target->ID, $instance->getTarget()->ID); |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
101 | $this->assertEquals($target->Title, $instance->getTarget()->Title); |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
102 | } |
||
103 | |||
104 | public function testPublishAction() { |
||
105 | $this->logInWithPermission(); |
||
106 | |||
107 | $action = new PublishItemWorkflowAction; |
||
108 | $instance = new WorkflowInstance(); |
||
109 | |||
110 | $page = new Page(); |
||
111 | $page->Title = 'stuff'; |
||
112 | $page->write(); |
||
113 | |||
114 | $instance->TargetClass = 'Page'; |
||
0 ignored issues
–
show
The property
TargetClass does not exist on object<WorkflowInstance> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
115 | $instance->TargetID = $page->ID; |
||
0 ignored issues
–
show
The property
TargetID does not exist on object<WorkflowInstance> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
116 | |||
117 | $this->assertFalse($page->isPublished()); |
||
0 ignored issues
–
show
The method
assertFalse() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
118 | |||
119 | $action->execute($instance); |
||
120 | |||
121 | $page = DataObject::get_by_id('Page', $page->ID); |
||
122 | $this->assertTrue($page->isPublished()); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
123 | |||
124 | } |
||
125 | |||
126 | public function testCreateDefinitionWithEmptyTitle() { |
||
127 | $definition = new WorkflowDefinition(); |
||
128 | $definition->Title = ""; |
||
0 ignored issues
–
show
The property
Title does not exist on object<WorkflowDefinition> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
129 | $definition->write(); |
||
130 | $this->assertContains('My Workflow',$definition->Title,'Workflow created without title is assigned a default title.'); |
||
0 ignored issues
–
show
The property
Title does not exist on object<WorkflowDefinition> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
131 | } |
||
132 | |||
133 | View Code Duplication | protected function createDefinition() { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
134 | $definition = new WorkflowDefinition(); |
||
135 | $definition->Title = "Dummy Workflow Definition"; |
||
0 ignored issues
–
show
The property
Title does not exist on object<WorkflowDefinition> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
136 | $definition->write(); |
||
137 | |||
138 | $stepOne = new WorkflowAction(); |
||
139 | $stepOne->Title = "Step One"; |
||
0 ignored issues
–
show
The property
Title does not exist on object<WorkflowAction> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
140 | $stepOne->WorkflowDefID = $definition->ID; |
||
0 ignored issues
–
show
The property
WorkflowDefID does not exist on object<WorkflowAction> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
141 | $stepOne->write(); |
||
142 | |||
143 | $stepTwo = new WorkflowAction(); |
||
144 | $stepTwo->Title = "Step Two"; |
||
0 ignored issues
–
show
The property
Title does not exist on object<WorkflowAction> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
145 | $stepTwo->WorkflowDefID = $definition->ID; |
||
0 ignored issues
–
show
The property
WorkflowDefID does not exist on object<WorkflowAction> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
146 | $stepTwo->write(); |
||
147 | |||
148 | $transitionOne = new WorkflowTransition(); |
||
149 | $transitionOne->Title = 'Step One T1'; |
||
0 ignored issues
–
show
The property
Title does not exist on object<WorkflowTransition> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
150 | $transitionOne->ActionID = $stepOne->ID; |
||
0 ignored issues
–
show
The property
ActionID does not exist on object<WorkflowTransition> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
151 | $transitionOne->NextActionID = $stepTwo->ID; |
||
0 ignored issues
–
show
The property
NextActionID does not exist on object<WorkflowTransition> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?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. ![]() |
|||
152 | $transitionOne->write(); |
||
153 | |||
154 | return $definition; |
||
155 | } |
||
156 | |||
157 | |||
158 | public function testCreateFromTemplate() { |
||
159 | $structure = array( |
||
160 | 'First step' => array( |
||
161 | 'type' => 'AssignUsersToWorkflowAction', |
||
162 | 'transitions' => array( |
||
163 | 'second' => 'Second step' |
||
164 | ) |
||
165 | ), |
||
166 | 'Second step' => array( |
||
167 | 'type' => 'NotifyUsersWorkflowAction', |
||
168 | 'transitions' => array( |
||
169 | 'Approve' => 'Third step' |
||
170 | ) |
||
171 | ), |
||
172 | ); |
||
173 | |||
174 | $template = new WorkflowTemplate('Test'); |
||
175 | |||
176 | $template->setStructure($structure); |
||
177 | |||
178 | $actions = $template->createRelations(); |
||
179 | |||
180 | $this->assertEquals(2, count($actions)); |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
181 | $this->assertTrue(isset($actions['First step'])); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
182 | $this->assertTrue(isset($actions['Second step'])); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
183 | |||
184 | $this->assertTrue($actions['First step']->exists()); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
185 | |||
186 | $transitions = $actions['First step']->Transitions(); |
||
187 | |||
188 | $this->assertTrue($transitions->count() == 1); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
189 | |||
190 | |||
191 | } |
||
192 | |||
193 | /** |
||
194 | * Tests whether if user(s) are able to delete a workflow, dependent on permissions. |
||
195 | */ |
||
196 | public function testCanDeleteWorkflow() { |
||
197 | // Create a definition |
||
198 | $def = $this->createDefinition(); |
||
199 | |||
200 | // Test a user with lame permissions |
||
201 | $memberID = $this->logInWithPermission('SITETREE_VIEW_ALL'); |
||
202 | $member = DataObject::get_by_id('Member', $memberID); |
||
203 | $this->assertFalse($def->canCreate($member)); |
||
0 ignored issues
–
show
$member is of type object<DataObject> , but the function expects a object<Member>|null .
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);
![]() The method
assertFalse() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
204 | |||
205 | // Test a user with good permissions |
||
206 | $memberID = $this->logInWithPermission('CREATE_WORKFLOW'); |
||
207 | $member = DataObject::get_by_id('Member', $memberID); |
||
208 | $this->assertTrue($def->canCreate($member)); |
||
0 ignored issues
–
show
$member is of type object<DataObject> , but the function expects a object<Member>|null .
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);
![]() The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
209 | } |
||
210 | |||
211 | /** |
||
212 | * For a context around this test, see: https://github.com/silverstripe-australia/advancedworkflow/issues/141 |
||
213 | * |
||
214 | * 1). Create a workflow definition |
||
215 | * 2). Step the content into that workflow |
||
216 | * 3). Delete the workflow |
||
217 | * 4). Check that the content: |
||
218 | * i). Has no remaining related actions |
||
219 | * ii). Can be re-assigned a new Workflow |
||
220 | * 5). Check that the object under workflow, maintains its status (Draft, Published etc) |
||
221 | */ |
||
222 | public function testDeleteWorkflowTargetStillWorks() { |
||
223 | // 1). Create a workflow definition |
||
224 | $def = $this->createDefinition(); |
||
225 | $page = Page::create(); |
||
226 | $page->Title = 'dummy test'; |
||
227 | $page->WorkflowDefinitionID = $def->ID; // Normally done via CMS |
||
228 | Versioned::reading_stage('Stage'); |
||
229 | $page->write(); |
||
230 | |||
231 | // Check $page is in draft, pre-deletion |
||
232 | $status = ($page->getIsAddedToStage() && !$page->getExistsOnLive()); |
||
233 | $this->assertTrue($status); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
234 | |||
235 | // 2). Step the content into that workflow |
||
236 | $instance = new WorkflowInstance(); |
||
237 | $instance->beginWorkflow($def, $page); |
||
238 | $instance->execute(); |
||
239 | |||
240 | // Check the content is assigned |
||
241 | $testPage = DataObject::get_by_id('Page', $page->ID); |
||
242 | $this->assertEquals($instance->TargetID, $testPage->ID); |
||
0 ignored issues
–
show
The property
TargetID does not exist on object<WorkflowInstance> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
243 | |||
244 | // 3). Delete the workflow |
||
245 | $def->delete(); |
||
246 | |||
247 | // Check $testPage is _still_ in draft, post-deletion |
||
248 | $status = ($testPage->getIsAddedToStage() && !$testPage->getExistsOnLive()); |
||
0 ignored issues
–
show
|
|||
249 | $this->assertTrue($status); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
250 | |||
251 | /* |
||
252 | * 4). i). Check that the content: Has no remaining related actions |
||
253 | * Note: WorkflowApplicable::WorkflowDefinitionID does _not_ get updated until assigned a new workflow |
||
254 | * so we can use it to check that all related actions are gone |
||
255 | */ |
||
256 | $defID = $testPage->WorkflowDefinitionID; |
||
257 | $this->assertEquals(0, DataObject::get('WorkflowAction')->filter('WorkflowDefID', $defID)->count()); |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
258 | |||
259 | /* |
||
260 | * 4). ii). Check that the content: Can be re-assigned a new Workflow Definition |
||
261 | */ |
||
262 | $newDef = $this->createDefinition(); |
||
263 | $testPage->WorkflowDefinitionID = $newDef->ID; // Normally done via CMS |
||
264 | $instance = new WorkflowInstance(); |
||
265 | $instance->beginWorkflow($newDef, $testPage); |
||
266 | $instance->execute(); |
||
267 | |||
268 | // Check the content is assigned to the new Workflow Definition correctly |
||
269 | $this->assertEquals($newDef->ID, $testPage->WorkflowDefinitionID); |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
270 | $this->assertEquals($newDef->Actions()->count(), DataObject::get('WorkflowAction')->filter('WorkflowDefID', $newDef->ID)->count()); |
||
0 ignored issues
–
show
The method
Actions() does not exist on WorkflowDefinition . Did you maybe mean updateAdminActions() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. ![]() The method
assertEquals() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
271 | |||
272 | // 5). Check that the object under workflow, maintains its status |
||
273 | $newDef2 = $this->createDefinition(); |
||
274 | |||
275 | // Login so SiteTree::canPublish() returns true |
||
276 | $testPage->WorkflowDefinitionID = $newDef2->ID; // Normally done via CMS |
||
277 | $this->logInWithPermission(); |
||
278 | $testPage->doPublish(); |
||
279 | |||
280 | // Check $testPage is published, pre-deletion (getStatusFlags() returns empty array) |
||
281 | $this->assertTrue($testPage->getExistsOnLive()); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
282 | |||
283 | $instance = new WorkflowInstance(); |
||
284 | $instance->beginWorkflow($newDef2, $testPage); |
||
285 | $instance->execute(); |
||
286 | |||
287 | // Now delete the related WorkflowDefinition and ensure status is the same (i.e. so it's not 'modified' for example) |
||
288 | $newDef2->delete(); |
||
289 | |||
290 | // Check $testPage is _still_ published, post-deletion (getStatusFlags() returns empty array) |
||
291 | $this->assertTrue($testPage->getExistsOnLive()); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEngineTest> .
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. ![]() |
|||
292 | } |
||
293 | } |
||
294 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.