$this->drupalPostForm('node/'.$node->id().'/edit',$edit,t('Save and publish'));
$this->assertRaw(t("The 'publish on' date must be in the future"),'An error message is shown when the publication date is in the past and the "error" behavior is chosen.');
// Test the 'publish' behavior: the node should be published immediately.
$this->drupalPostForm('node/'.$node->id().'/edit',$edit,t('Save and publish'));
$this->assertNoRaw(t("The 'publish on' date must be in the future"),'No error message is shown when the publication date is in the past and the "publish" behavior is chosen.');
$this->assertRaw(t('@type %title has been updated.',array('@type'=>t('Basic page'),'%title'=>SafeMarkup::checkPlain($edit['title']))),'The node is saved successfully when the publication date is in the past and the "publish" behavior is chosen.');
$this->assertRaw(t('@type %title has been updated.',array('@type'=>t('Basic page'),'%title'=>SafeMarkup::checkPlain($edit['title[0][value]']))),'The node is saved successfully when the publication date is in the past and the "publish" behavior is chosen.');
// Reload the changed node and check that it is published.
$node_storage->resetCache(array($node->id()));
@@ -105,17 +114,18 @@ class SchedulerFunctionalTest extends SchedulerTestBase {
// Test the 'schedule' behavior: the node should be unpublished and become
$this->drupalPostForm('node/'.$node->id().'/edit',$edit,t('Save and publish'));
$publish_time=$edit['publish_on[0][value][date]'].' '.$edit['publish_on[0][value][time]'];### @TODO should use date format from config
$this->assertNoRaw(t("The 'publish on' date must be in the future"),'No error message is shown when the publication date is in the past and the "schedule" behavior is chosen.');
$this->assertRaw(t('@type %title has been updated.',array('@type'=>t('Basic page'),'%title'=>SafeMarkup::checkPlain($edit['title']))),'The node is saved successfully when the publication date is in the past and the "schedule" behavior is chosen.');
$this->assertRaw(t('This post is unpublished and will be published @publish_time.',array('@publish_time'=>$edit['publish_on'])),'The node is scheduled to be published when the publication date is in the past and the "schedule" behavior is chosen.');
$this->assertRaw(t('@type %title has been updated.',array('@type'=>t('Basic page'),'%title'=>SafeMarkup::checkPlain($edit['title[0][value]']))),'The node is saved successfully when the publication date is in the past and the "schedule" behavior is chosen.');
$this->assertRaw(t('This post is unpublished and will be published @publish_time.',array('@publish_time'=>$publish_time)),'The node is scheduled to be published when the publication date is in the past and the "schedule" behavior is chosen.');
// Reload the node and check that it is unpublished but scheduled correctly.
$node_storage->resetCache(array($node->id()));
$node=$node_storage->load($node->id());
$this->assertFalse($node->isPublished(),'The node has been unpublished when the publication date is in the past and the "schedule" behavior is chosen.');
$this->assertEqual(format_date($node->publish_on->value,'custom','Y-m-d H:i:s'),$edit['publish_on'],'The node is scheduled for the required date');
$this->assertEqual(format_date($node->publish_on->value,'custom','Y-m-d H:i:s'),$publish_time,'The node is scheduled for the required date');
// Simulate a cron run and check that the node is published.
scheduler_cron();
@@ -128,7 +138,6 @@ class SchedulerFunctionalTest extends SchedulerTestBase {
* Tests the creation of new revisions on scheduling.
*/
publicfunctiontestRevisioning(){
$config=$this->config('scheduler.settings');
// Create a scheduled node that is not automatically revisioned.
$created=strtotime('-2 day');
$settings=array(
@@ -146,8 +155,9 @@ class SchedulerFunctionalTest extends SchedulerTestBase {
$this->assertRevisionCount($node->id(),1,'No new revision was created when a node was unpublished with revisioning disabled.');
// Test scheduled publication with revisioning enabled.
$node=$this->schedule($node);
@@ -172,7 +182,7 @@ class SchedulerFunctionalTest extends SchedulerTestBase {
* Tests if options can both be displayed as extra fields and vertical tabs.
*/
publicfunctiontestExtraFields(){
$config=$this->config('scheduler.settings');
$node_type=NodeType::load('page');
$this->drupalLogin($this->adminUser);
// Test if the options are shown as vertical tabs by default.
@@ -180,13 +190,13 @@ class SchedulerFunctionalTest extends SchedulerTestBase {
$this->assertTrue($this->xpath('//div[contains(@class, "vertical-tabs-panes")]/fieldset[@id = "edit-scheduler-settings"]'),'By default the scheduler options are shown as a vertical tab.');
// Test if the options are shown as extra fields when configured to do so.
$this->assertFalse($this->xpath('//div[contains(@class, "vertical-tabs-panes")]/fieldset[@id = "edit-scheduler-settings"]'),'The scheduler options are not shown as a vertical tab when they are configured to show as an extra field.');
$this->assertTrue($this->xpath('//fieldset[@id = "edit-scheduler-settings" and contains(@class, "collapsed")]'),'The scheduler options are shown as a collapsed fieldset when they are configured to show as an extra field.');
$this->assertFalse($this->xpath('//div[contains(@class, "vertical-tabs-panes")]/fieldset[@id = "edit-scheduler-settings"]'),'The scheduler options are not shown as a vertical tab when they are configured to show as an expanded fieldset.');
$this->assertTrue($this->xpath('//fieldset[@id = "edit-scheduler-settings" and not(contains(@class, "collapsed"))]'),'The scheduler options are shown as an expanded fieldset.');
@@ -326,14 +336,22 @@ class SchedulerFunctionalTest extends SchedulerTestBase {
),
);
foreach($test_casesas$test_case){
$node_type=NodeType::load('page');
foreach($test_casesas$key=>$test_case){
// Enable required (un)publishing as stipulated by the test case.
$this->drupalPostForm('node/'.$node->id().'/edit',$edit,t('Save and keep unpublished'));
$this->assertRaw(t("If you set a 'publish-on' date then you must also set an 'unpublish-on' date."),'Validation prevents entering a publish-on date with no unpublish-on date if unpublishing is required.');
}
@@ -419,7 +446,6 @@ class SchedulerFunctionalTest extends SchedulerTestBase {
* @see https://drupal.org/node/1614880
*/
publicfunctiontestScheduledNodeDelete(){
$config=$this->config('scheduler.settings');
// Log in.
$this->drupalLogin($this->adminUser);
@@ -428,14 +454,19 @@ class SchedulerFunctionalTest extends SchedulerTestBase {