/**
  * @todo Test the results of a publication better
  */
 public function testPublish()
 {
     $page1 = $this->objFromFixture('Page', "page1");
     $page2 = $this->objFromFixture('Page', "page2");
     $this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
     $response = $this->get('admin/pages/publishall?confirm=1');
     $this->assertContains('Done: Published 30 pages', $response->getBody());
     $actions = CMSBatchActionHandler::config()->batch_actions;
     // Some modules (e.g., cmsworkflow) will remove this action
     $actions = CMSBatchActionHandler::config()->batch_actions;
     if (isset($actions['publish'])) {
         $response = $this->get('admin/pages/batchactions/publish?ajax=1&csvIDs=' . implode(',', array($page1->ID, $page2->ID)));
         $responseData = Convert::json2array($response->getBody());
         $this->assertArrayHasKey($page1->ID, $responseData['modified']);
         $this->assertArrayHasKey($page2->ID, $responseData['modified']);
     }
     // Get the latest version of the redirector page
     $pageID = $this->idFromFixture('RedirectorPage', 'page5');
     $latestID = DB::query('select max("Version") from "RedirectorPage_versions" where "RecordID"=' . $pageID)->value();
     $dsCount = DB::query('select count("Version") from "RedirectorPage_versions" where "RecordID"=' . $pageID . ' and "Version"=' . $latestID)->value();
     $this->assertEquals(1, $dsCount, "Published page has no duplicate version records: it has " . $dsCount . " for version " . $latestID);
     $this->session()->clear('loggedInAs');
     //$this->assertRegexp('/Done: Published 4 pages/', $response->getBody())
     /*
     $response = Director::test("admin/pages/publishitems", array(
     	'ID' => ''
     	'Title' => ''
     	'action_publish' => 'Save and publish',
     ), $session);
     $this->assertRegexp('/Done: Published 4 pages/', $response->getBody())
     */
 }
Exemplo n.º 2
0
 public function BatchActionParameters()
 {
     $batchActions = CMSBatchActionHandler::config()->batch_actions;
     $forms = array();
     foreach ($batchActions as $urlSegment => $batchAction) {
         $SNG_action = singleton($batchAction);
         if ($SNG_action->canView() && ($fieldset = $SNG_action->getParameterFields())) {
             $formHtml = '';
             foreach ($fieldset as $field) {
                 $formHtml .= $field->Field();
             }
             $forms[$urlSegment] = $formHtml;
         }
     }
     $pageHtml = '';
     foreach ($forms as $urlSegment => $html) {
         $pageHtml .= "<div class=\"params\" id=\"BatchActionParameters_{$urlSegment}\">{$html}</div>\n\n";
     }
     return new LiteralField("BatchActionParameters", '<div id="BatchActionParameters" style="display:none">' . $pageHtml . '</div>');
 }