@@ 140-188 (lines=49) @@ | ||
137 | /** |
|
138 | * Test that a page with a past publish date creates the correct jobs |
|
139 | */ |
|
140 | public function testPastPublishThenUnpublish() |
|
141 | { |
|
142 | $page = new Page(); |
|
143 | $page->Title = 'My Page'; |
|
144 | $page->write(); |
|
145 | ||
146 | // No publish |
|
147 | $this->assertEmpty($page->PublishJobID); |
|
148 | $this->assertEmpty($page->UnPublishJobID); |
|
149 | ||
150 | // Set a past publish date |
|
151 | $page->PublishOnDate = '2010-01-01 00:00:00'; |
|
152 | $page->write(); |
|
153 | ||
154 | // We should still have a job to publish this page, but not unpublish |
|
155 | $this->assertNotEmpty($page->PublishJobID); |
|
156 | $this->assertEmpty($page->UnPublishJobID); |
|
157 | ||
158 | // Check that this job is set for immediate run |
|
159 | $publish = strtotime($page->PublishJob()->StartAfter); |
|
160 | $this->assertEmpty($publish); |
|
161 | ||
162 | // Now add an expiry date in the past, but after the current publish job, |
|
163 | // and ensure that this correctly overrides the open publish request |
|
164 | $page->UnPublishOnDate = '2010-01-02 00:00:00'; |
|
165 | $page->write(); |
|
166 | ||
167 | // Now we should have an unpublish job, but the publish job is noticably absent |
|
168 | $this->assertEmpty($page->PublishJobID); |
|
169 | $this->assertNotEmpty($page->UnPublishJobID); |
|
170 | ||
171 | // Check that this unpublish job is set for immediate run |
|
172 | $unpublish = strtotime($page->UnPublishJob()->StartAfter); |
|
173 | $this->assertEmpty($unpublish); |
|
174 | ||
175 | // Now add an expiry date in the future, and ensure that we get the correct combination of |
|
176 | // publish and unpublish jobs |
|
177 | $page->UnPublishOnDate = '2015-01-01 12:00:00'; |
|
178 | $page->write(); |
|
179 | ||
180 | // Both jobs exist |
|
181 | $this->assertNotEmpty($page->PublishJobID); |
|
182 | $this->assertNotEmpty($page->UnPublishJobID); |
|
183 | ||
184 | // Check that this unpublish job is set for immediate run and the unpublish for future |
|
185 | $publish = strtotime($page->PublishJob()->StartAfter); |
|
186 | $unpublish = strtotime($page->UnPublishJob()->StartAfter); |
|
187 | $this->assertEmpty($publish); // for immediate run |
|
188 | $this->assertGreaterThan(strtotime(SS_Datetime::now()->getValue()), $unpublish); // for later run |
|
189 | } |
|
190 | ||
191 | /** |
|
@@ 194-242 (lines=49) @@ | ||
191 | /** |
|
192 | * Test that a page with a past unpublish date creates the correct jobs |
|
193 | */ |
|
194 | public function testPastUnPublishThenPublish() |
|
195 | { |
|
196 | $page = new Page(); |
|
197 | $page->Title = 'My Page'; |
|
198 | $page->write(); |
|
199 | ||
200 | // No publish |
|
201 | $this->assertEmpty($page->PublishJobID); |
|
202 | $this->assertEmpty($page->UnPublishJobID); |
|
203 | ||
204 | // Set a past unpublish date |
|
205 | $page->UnPublishOnDate = '2010-01-01 00:00:00'; |
|
206 | $page->write(); |
|
207 | ||
208 | // We should still have a job to unpublish this page, but not publish |
|
209 | $this->assertEmpty($page->PublishJobID); |
|
210 | $this->assertNotEmpty($page->UnPublishJobID); |
|
211 | ||
212 | // Check that this job is set for immediate run |
|
213 | $unpublish = strtotime($page->UnPublishJob()->StartAfter); |
|
214 | $this->assertEmpty($unpublish); |
|
215 | ||
216 | // Now add an publish date in the past, but after the unpublish job, |
|
217 | // and ensure that this correctly overrides the open unpublish request |
|
218 | $page->PublishOnDate = '2010-01-02 00:00:00'; |
|
219 | $page->write(); |
|
220 | ||
221 | // Now we should have an publish job, but the unpublish job is noticably absent |
|
222 | $this->assertNotEmpty($page->PublishJobID); |
|
223 | $this->assertEmpty($page->UnPublishJobID); |
|
224 | ||
225 | // Check that this publish job is set for immediate run |
|
226 | $publish = strtotime($page->PublishJob()->StartAfter); |
|
227 | $this->assertEmpty($publish); |
|
228 | ||
229 | // Now add a publish date in the future, and ensure that we get the correct combination of |
|
230 | // publish and unpublish jobs |
|
231 | $page->PublishOnDate = '2015-01-01 12:00:00'; |
|
232 | $page->write(); |
|
233 | ||
234 | // Both jobs exist |
|
235 | $this->assertNotEmpty($page->PublishJobID); |
|
236 | $this->assertNotEmpty($page->UnPublishJobID); |
|
237 | ||
238 | // Check that this unpublish job is set for immediate run and the unpublish for future |
|
239 | $publish = strtotime($page->PublishJob()->StartAfter); |
|
240 | $unpublish = strtotime($page->UnPublishJob()->StartAfter); |
|
241 | $this->assertEmpty($unpublish); // for immediate run |
|
242 | $this->assertGreaterThan(strtotime(SS_Datetime::now()->getValue()), $publish); // for later run |
|
243 | } |
|
244 | ||
245 | public function testPastPublishWithWorkflowInEffect() |