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 | /** |
||
4 | * @author [email protected] |
||
5 | * @license BSD License http://silverstripe.org/bsd-license/ |
||
6 | */ |
||
7 | class WorkflowEmbargoExpiryTest extends SapphireTest { |
||
0 ignored issues
–
show
|
|||
8 | |||
9 | public function setUp() { |
||
10 | parent::setUp(); |
||
11 | |||
12 | SS_Datetime::set_mock_now('2014-01-05 12:00:00'); |
||
13 | } |
||
14 | |||
15 | public function tearDown() { |
||
16 | SS_Datetime::clear_mock_now(); |
||
17 | parent::tearDown(); |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $requiredExtensions = array( |
||
24 | 'SiteTree' => array( |
||
25 | 'WorkflowEmbargoExpiryExtension', |
||
26 | 'Versioned', |
||
27 | ) |
||
28 | ); |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $illegalExtensions = array( |
||
34 | 'SiteTree' => array( |
||
35 | "Translatable", |
||
36 | ) |
||
37 | ); |
||
38 | |||
39 | public function __construct() { |
||
40 | if(!class_exists('AbstractQueuedJob')) { |
||
41 | $this->skipTest = true; |
||
42 | } |
||
43 | parent::__construct(); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
SapphireTest as the method __construct() does only exist in the following sub-classes of SapphireTest : FileFinderTest , ManifestFileFinderTest , MemberTest , WorkflowEmbargoExpiryTest . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
44 | } |
||
45 | |||
46 | public function testFutureDatesJobs() { |
||
47 | $page = new Page(); |
||
48 | |||
49 | $page->PublishOnDate = '2020-01-01 00:00:00'; |
||
50 | $page->UnPublishOnDate = '2020-01-01 01:00:00'; |
||
51 | |||
52 | // Two writes are necessary for this to work on new objects |
||
53 | $page->write(); |
||
54 | $page->write(); |
||
55 | |||
56 | $this->assertTrue($page->PublishJobID > 0); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
57 | $this->assertTrue($page->UnPublishJobID > 0); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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 | // Check date ranges |
||
60 | $now = strtotime(SS_Datetime::now()->getValue()); |
||
61 | $publish = strtotime($page->PublishJob()->StartAfter); |
||
62 | $unPublish = strtotime($page->UnPublishJob()->StartAfter); |
||
63 | |||
64 | $this->assertGreaterThan($now, $publish); |
||
0 ignored issues
–
show
The method
assertGreaterThan() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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 | $this->assertGreaterThan($now, $unPublish); |
||
0 ignored issues
–
show
The method
assertGreaterThan() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
66 | $this->assertGreaterThan($publish, $unPublish); |
||
0 ignored issues
–
show
The method
assertGreaterThan() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
67 | } |
||
68 | |||
69 | public function testDesiredRemovesJobs() { |
||
70 | $page = new Page(); |
||
71 | |||
72 | $page->PublishOnDate = '2020-01-01 00:00:00'; |
||
73 | $page->UnPublishOnDate = '2020-01-01 01:00:00'; |
||
74 | |||
75 | // Two writes are necessary for this to work on new objects |
||
76 | $page->write(); |
||
77 | $page->write(); |
||
78 | |||
79 | $this->assertTrue($page->PublishJobID > 0); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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->assertTrue($page->UnPublishJobID > 0); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
81 | |||
82 | // Check date ranges |
||
83 | $now = strtotime(SS_Datetime::now()->getValue()); |
||
84 | $publish = strtotime($page->PublishJob()->StartAfter); |
||
85 | $unPublish = strtotime($page->UnPublishJob()->StartAfter); |
||
86 | |||
87 | $this->assertGreaterThan($now, $publish); |
||
0 ignored issues
–
show
The method
assertGreaterThan() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
88 | $this->assertGreaterThan($now, $unPublish); |
||
0 ignored issues
–
show
The method
assertGreaterThan() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
89 | $this->assertGreaterThan($publish, $unPublish); |
||
0 ignored issues
–
show
The method
assertGreaterThan() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
90 | |||
91 | $page->DesiredPublishDate = '2020-02-01 00:00:00'; |
||
92 | $page->DesiredUnPublishDate = '2020-02-01 02:00:00'; |
||
93 | |||
94 | $page->write(); |
||
95 | |||
96 | $this->assertTrue($page->PublishJobID == 0); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
97 | $this->assertTrue($page->UnPublishJobID == 0); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
98 | } |
||
99 | |||
100 | public function testPublishActionWithFutureDates() { |
||
101 | $action = new PublishItemWorkflowAction(); |
||
102 | $instance = new WorkflowInstance(); |
||
103 | |||
104 | $page = new Page(); |
||
105 | $page->Title = 'stuff'; |
||
106 | $page->DesiredPublishDate = '2020-02-01 00:00:00'; |
||
107 | $page->DesiredUnPublishDate = '2020-02-01 02:00:00'; |
||
108 | |||
109 | $page->write(); |
||
110 | |||
111 | $instance->TargetClass = $page->ClassName; |
||
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. ![]() |
|||
112 | $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. ![]() |
|||
113 | |||
114 | $action->execute($instance); |
||
115 | |||
116 | $page = DataObject::get_by_id('Page', $page->ID); |
||
117 | $this->assertTrue($page->PublishJobID > 0); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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 | $this->assertTrue($page->UnPublishJobID > 0); |
||
0 ignored issues
–
show
The method
assertTrue() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
119 | |||
120 | // Check date ranges |
||
121 | $now = strtotime(SS_Datetime::now()->getValue()); |
||
122 | $publish = strtotime($page->PublishJob()->StartAfter); |
||
123 | $unPublish = strtotime($page->UnPublishJob()->StartAfter); |
||
124 | |||
125 | $this->assertGreaterThan($now, $publish); |
||
0 ignored issues
–
show
The method
assertGreaterThan() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
126 | $this->assertGreaterThan($now, $unPublish); |
||
0 ignored issues
–
show
The method
assertGreaterThan() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
127 | $this->assertGreaterThan($publish, $unPublish); |
||
0 ignored issues
–
show
The method
assertGreaterThan() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
128 | } |
||
129 | |||
130 | /** |
||
131 | * Test that a page with a past publish date creates the correct jobs |
||
132 | */ |
||
133 | View Code Duplication | public function testPastPublishThenUnpublish() { |
|
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 | $page = new Page(); |
||
135 | $page->Title = 'My Page'; |
||
136 | $page->write(); |
||
137 | |||
138 | // No publish |
||
139 | $this->assertEmpty($page->PublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
140 | $this->assertEmpty($page->UnPublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
141 | |||
142 | // Set a past publish date |
||
143 | $page->PublishOnDate = '2010-01-01 00:00:00'; |
||
144 | $page->write(); |
||
145 | |||
146 | // We should still have a job to publish this page, but not unpublish |
||
147 | $this->assertNotEmpty($page->PublishJobID); |
||
0 ignored issues
–
show
The method
assertNotEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
148 | $this->assertEmpty($page->UnPublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
149 | |||
150 | // Check that this job is set for immediate run |
||
151 | $publish = strtotime($page->PublishJob()->StartAfter); |
||
152 | $this->assertEmpty($publish); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
153 | |||
154 | // Now add an expiry date in the past, but after the current publish job, |
||
155 | // and ensure that this correctly overrides the open publish request |
||
156 | $page->UnPublishOnDate = '2010-01-02 00:00:00'; |
||
157 | $page->write(); |
||
158 | |||
159 | // Now we should have an unpublish job, but the publish job is noticably absent |
||
160 | $this->assertEmpty($page->PublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
161 | $this->assertNotEmpty($page->UnPublishJobID); |
||
0 ignored issues
–
show
The method
assertNotEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
162 | |||
163 | // Check that this unpublish job is set for immediate run |
||
164 | $unpublish = strtotime($page->UnPublishJob()->StartAfter); |
||
165 | $this->assertEmpty($unpublish); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
166 | |||
167 | // Now add an expiry date in the future, and ensure that we get the correct combination of |
||
168 | // publish and unpublish jobs |
||
169 | $page->UnPublishOnDate = '2015-01-01 12:00:00'; |
||
170 | $page->write(); |
||
171 | |||
172 | // Both jobs exist |
||
173 | $this->assertNotEmpty($page->PublishJobID); |
||
0 ignored issues
–
show
The method
assertNotEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
174 | $this->assertNotEmpty($page->UnPublishJobID); |
||
0 ignored issues
–
show
The method
assertNotEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
175 | |||
176 | // Check that this unpublish job is set for immediate run and the unpublish for future |
||
177 | $publish = strtotime($page->PublishJob()->StartAfter); |
||
178 | $unpublish = strtotime($page->UnPublishJob()->StartAfter); |
||
179 | $this->assertEmpty($publish); // for immediate run |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
180 | $this->assertGreaterThan(strtotime(SS_Datetime::now()->getValue()), $unpublish); // for later run |
||
0 ignored issues
–
show
The method
assertGreaterThan() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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 | } |
||
182 | |||
183 | /** |
||
184 | * Test that a page with a past unpublish date creates the correct jobs |
||
185 | */ |
||
186 | View Code Duplication | public function testPastUnPublishThenPublish() { |
|
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. ![]() |
|||
187 | $page = new Page(); |
||
188 | $page->Title = 'My Page'; |
||
189 | $page->write(); |
||
190 | |||
191 | // No publish |
||
192 | $this->assertEmpty($page->PublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
193 | $this->assertEmpty($page->UnPublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
194 | |||
195 | // Set a past unpublish date |
||
196 | $page->UnPublishOnDate = '2010-01-01 00:00:00'; |
||
197 | $page->write(); |
||
198 | |||
199 | // We should still have a job to unpublish this page, but not publish |
||
200 | $this->assertEmpty($page->PublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
201 | $this->assertNotEmpty($page->UnPublishJobID); |
||
0 ignored issues
–
show
The method
assertNotEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
202 | |||
203 | // Check that this job is set for immediate run |
||
204 | $unpublish = strtotime($page->UnPublishJob()->StartAfter); |
||
205 | $this->assertEmpty($unpublish); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
206 | |||
207 | // Now add an publish date in the past, but after the unpublish job, |
||
208 | // and ensure that this correctly overrides the open unpublish request |
||
209 | $page->PublishOnDate = '2010-01-02 00:00:00'; |
||
210 | $page->write(); |
||
211 | |||
212 | // Now we should have an publish job, but the unpublish job is noticably absent |
||
213 | $this->assertNotEmpty($page->PublishJobID); |
||
0 ignored issues
–
show
The method
assertNotEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
214 | $this->assertEmpty($page->UnPublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
215 | |||
216 | // Check that this publish job is set for immediate run |
||
217 | $publish = strtotime($page->PublishJob()->StartAfter); |
||
218 | $this->assertEmpty($publish); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
219 | |||
220 | // Now add a publish date in the future, and ensure that we get the correct combination of |
||
221 | // publish and unpublish jobs |
||
222 | $page->PublishOnDate = '2015-01-01 12:00:00'; |
||
223 | $page->write(); |
||
224 | |||
225 | // Both jobs exist |
||
226 | $this->assertNotEmpty($page->PublishJobID); |
||
0 ignored issues
–
show
The method
assertNotEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
227 | $this->assertNotEmpty($page->UnPublishJobID); |
||
0 ignored issues
–
show
The method
assertNotEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
228 | |||
229 | // Check that this unpublish job is set for immediate run and the unpublish for future |
||
230 | $publish = strtotime($page->PublishJob()->StartAfter); |
||
231 | $unpublish = strtotime($page->UnPublishJob()->StartAfter); |
||
232 | $this->assertEmpty($unpublish); // for immediate run |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
233 | $this->assertGreaterThan(strtotime(SS_Datetime::now()->getValue()), $publish); // for later run |
||
0 ignored issues
–
show
The method
assertGreaterThan() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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 | |||
236 | public function testPastPublishWithWorkflowInEffect() { |
||
237 | $definition = $this->createDefinition(); |
||
238 | |||
239 | $page = new Page(); |
||
240 | $page->Title = 'My page'; |
||
241 | $page->WorkflowDefinitionID = $definition->ID; |
||
242 | $page->write(); |
||
243 | |||
244 | // No publish |
||
245 | $this->assertEmpty($page->PublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
246 | $this->assertEmpty($page->UnPublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
247 | |||
248 | // Set a past publish date |
||
249 | $page->DesiredPublishDate = '2010-01-01 00:00:00'; |
||
250 | $page->write(); |
||
251 | |||
252 | // Workflow is in effect. No jobs have been created yet as it's not approved. |
||
253 | $this->assertEmpty($page->PublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
254 | $this->assertEmpty($page->UnPublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
255 | |||
256 | // Advance the workflow so we can see what happens |
||
257 | $instance = new WorkflowInstance(); |
||
258 | $instance->beginWorkflow($definition, $page); |
||
259 | $instance->execute(); |
||
260 | |||
261 | // execute the "publish" workflow action |
||
262 | $action = new PublishItemWorkflowAction(); |
||
263 | $action->execute($instance); |
||
264 | |||
265 | // re-fetch the Page again. |
||
266 | $page = Page::get()->byId($page->ID); |
||
267 | |||
268 | // We now have a PublishOnDate field set |
||
269 | $this->assertEquals('2010-01-01 00:00:00', $page->PublishOnDate); |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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->assertEmpty($page->DesiredPublishDate); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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 | // Publish job has been setup |
||
273 | $this->assertNotEmpty($page->PublishJobID); |
||
0 ignored issues
–
show
The method
assertNotEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
274 | $this->assertEmpty($page->UnPublishJobID); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
275 | |||
276 | // Check that this publish job is set for immediate run |
||
277 | $publish = strtotime($page->PublishJob()->StartAfter); |
||
278 | $this->assertEmpty($publish); |
||
0 ignored issues
–
show
The method
assertEmpty() does not seem to exist on object<WorkflowEmbargoExpiryTest> .
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. ![]() |
|||
279 | } |
||
280 | |||
281 | 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. ![]() |
|||
282 | $definition = new WorkflowDefinition(); |
||
283 | $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. ![]() |
|||
284 | $definition->write(); |
||
285 | |||
286 | $stepOne = new WorkflowAction(); |
||
287 | $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. ![]() |
|||
288 | $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. ![]() |
|||
289 | $stepOne->write(); |
||
290 | |||
291 | $stepTwo = new WorkflowAction(); |
||
292 | $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. ![]() |
|||
293 | $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. ![]() |
|||
294 | $stepTwo->write(); |
||
295 | |||
296 | $transitionOne = new WorkflowTransition(); |
||
297 | $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. ![]() |
|||
298 | $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. ![]() |
|||
299 | $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. ![]() |
|||
300 | $transitionOne->write(); |
||
301 | |||
302 | return $definition; |
||
303 | } |
||
304 | |||
305 | } |
||
306 |
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.