public function testCanViewStage()
 {
     // Create a new page
     $page = new Page();
     $page->URLSegment = 'testpage';
     $page->write();
     $page->publish('Stage', 'Live');
     // Add a stage-only version
     $page->Content = "Version2";
     $page->write();
     $response = $this->get('/testpage');
     $this->assertEquals($response->getStatusCode(), 200, "Doesn't require login for implicit live stage");
     $response = $this->get('/testpage/?stage=Live');
     $this->assertEquals($response->getStatusCode(), 200, "Doesn't require login for explicit live stage");
     try {
         $response = $this->get('/testpage/?stage=Stage');
     } catch (SS_HTTPResponse_Exception $responseException) {
         $response = $responseException->getResponse();
     }
     // should redirect to login
     $this->assertEquals($response->getStatusCode(), 302, 'Redirects to login page when not logged in for draft stage');
     $this->assertContains(Config::inst()->get('Security', 'login_url'), $response->getHeader('Location'));
     $this->logInWithPermission('CMS_ACCESS_CMSMain');
     $response = $this->get('/testpage/?stage=Stage');
     $this->assertEquals($response->getStatusCode(), 200, 'Doesnt redirect to login, but shows page for authenticated user');
 }
 protected function importItem($item, $parentObject, $duplicateStrategy)
 {
     if ($item) {
         $externalId = $item->getExternalId();
         $parentFilter = $parentObject ? ' AND "ParentID" = ' . (int) $parentObject->ID : '';
         $existing = DataObject::get_one('Page', '"MetaTitle" = \'' . $externalId . '\'' . $parentFilter);
         if ($existing && $existing->exists()) {
             if ($duplicateStrategy == ExternalContentTransformer::DS_SKIP) {
                 return;
             }
             if ($duplicateStrategy == ExternalContentTransformer::DS_DUPLICATE) {
                 $existing = new Page();
             }
         } else {
             $existing = new Page();
         }
         $existing->Title = 'Tweet: ' . $item->Title;
         $existing->MetaTitle = $externalId;
         $existing->Content = $item->Tweet;
         if ($parentObject) {
             $existing->ParentID = $parentObject->ID;
         }
         $existing->write();
         $existing->Created = date('Y-m-d H:i:s', strtotime($item->Created));
         $existing->LegacyURL = $item->Link;
         $existing->MetaDescription = 'Tweet from ' . $item->CreatedBy . ' at ' . $item->Created;
         $existing->write();
         return $existing;
     }
 }
 public function testFindOldPage()
 {
     $page = new Page();
     $page->Title = 'Test Page';
     $page->URLSegment = 'test-page';
     $page->write();
     $page->publish('Stage', 'Live');
     $page->URLSegment = 'test';
     $page->write();
     $page->publish('Stage', 'Live');
     $router = new ModelAsController();
     $request = new HTTPRequest('GET', 'test-page/action/id/otherid');
     $request->match('$URLSegment/$Action/$ID/$OtherID');
     $response = $router->handleRequest($request);
     $this->assertEquals($response->getHeader('Location'), Controller::join_links(Director::baseURL() . 'test/action/id/otherid'));
 }
 function testReadOnlyTransaction()
 {
     if (DB::get_conn()->supportsTransactions() == true && DB::get_conn() instanceof PostgreSQLDatabase) {
         $page = new Page();
         $page->Title = 'Read only success';
         $page->write();
         DB::get_conn()->transactionStart('READ ONLY');
         try {
             $page = new Page();
             $page->Title = 'Read only page failed';
             $page->write();
         } catch (Exception $e) {
             //could not write this record
             //We need to do a rollback or a commit otherwise we'll get error messages
             DB::get_conn()->transactionRollback();
         }
         DB::get_conn()->transactionEnd();
         DataObject::flush_and_destroy_cache();
         $success = DataObject::get('Page', "\"Title\"='Read only success'");
         $fail = DataObject::get('Page', "\"Title\"='Read only page failed'");
         //This page should be in the system
         $this->assertTrue(is_object($success) && $success->exists());
         //This page should NOT exist, we had 'read only' permissions
         $this->assertFalse(is_object($fail) && $fail->exists());
     } else {
         $this->markTestSkipped('Current database is not PostgreSQL');
     }
 }
 function testCreateWithTransaction()
 {
     if (DB::getConn()->supportsTransactions() == true) {
         DB::getConn()->transactionStart();
         $page = new Page();
         $page->Title = 'First page';
         $page->write();
         $page = new Page();
         $page->Title = 'Second page';
         $page->write();
         //Create a savepoint here:
         DB::getConn()->transactionSavepoint('rollback');
         $page = new Page();
         $page->Title = 'Third page';
         $page->write();
         $page = new Page();
         $page->Title = 'Forth page';
         $page->write();
         //Revert to a savepoint:
         DB::getConn()->transactionRollback('rollback');
         DB::getConn()->transactionEnd();
         $first = DataObject::get('Page', "\"Title\"='First page'");
         $second = DataObject::get('Page', "\"Title\"='Second page'");
         $third = DataObject::get('Page', "\"Title\"='Third page'");
         $forth = DataObject::get('Page', "\"Title\"='Forth page'");
         //These pages should be in the system
         $this->assertTrue(is_object($first) && $first->exists());
         $this->assertTrue(is_object($second) && $second->exists());
         //These pages should NOT exist, we reverted to a savepoint:
         $this->assertFalse(is_object($third) && $third->exists());
         $this->assertFalse(is_object($forth) && $forth->exists());
     } else {
         $this->markTestSkipped('Current database does not support transactions');
     }
 }
 protected function pageIsBrokenFile($content)
 {
     $page = new Page();
     $page->Content = $content;
     $page->write();
     return $page->HasBrokenFile;
 }
 function requireDefaultRecords()
 {
     if ($this->class == 'TestPage') {
         return;
     }
     $class = $this->class;
     if (!DataObject::get_one($class)) {
         // Try to create common parent
         $parent = SiteTree::get()->filter('URLSegment', 'feature-test-pages')->First();
         if (!$parent) {
             $parent = new Page(array('Title' => 'Feature Test Pages', 'Content' => 'A collection of pages for testing various features in the SilverStripe CMS', 'ShowInMenus' => 0));
             $parent->write();
             $parent->doPublish();
         }
         // Create actual page
         $page = new $class();
         $page->Title = str_replace("TestPage", "", $class);
         $page->ShowInMenus = 0;
         if ($parent) {
             $page->ParentID = $parent->ID;
         }
         $page->write();
         $page->publish('Stage', 'Live');
     }
 }
 function testReadOnlyTransaction()
 {
     if (DB::getConn()->supportsTransactions() == true) {
         $page = new Page();
         $page->Title = 'Read only success';
         $page->write();
         DB::getConn()->startTransaction('READ ONLY');
         try {
             $page = new Page();
             $page->Title = 'Read only page failed';
             $page->write();
         } catch (Exception $e) {
             //could not write this record
             //We need to do a rollback or a commit otherwise we'll get error messages
             DB::getConn()->transactionRollback();
         }
         DB::getConn()->endTransaction();
         $success = DataObject::get('Page', "\"Title\"='Read only success'");
         $fail = DataObject::get('Page', "\"Title\"='Read only failed'");
         //This page should be in the system
         $this->assertTrue(is_object($success) && $success->exists());
         //This page should NOT exist, we had 'read only' permissions
         $this->assertFalse(is_object($fail) && $fail->exists());
     }
 }
 function run($request)
 {
     $id = $request->getVar('ID');
     if (!is_numeric($id) && !preg_match('/^[0-9]+_[0-9]+$/', $id) || !$id) {
         echo "<p>Specify ?ID=(number) or ?ID=(ID)_(Code)</p>\n";
         return;
     }
     $includeSelected = false;
     $includeChildren = true;
     $duplicates = 'Duplicate';
     $selected = $id;
     $target = new Page();
     $target->Title = "Import on " . date('Y-m-d H:i:s');
     $target->write();
     $targetType = 'SiteTree';
     $from = ExternalContent::getDataObjectFor($selected);
     if ($from instanceof ExternalContentSource) {
         $selected = false;
     }
     $importer = null;
     $importer = $from->getContentImporter($targetType);
     if ($importer) {
         $importer->import($from, $target, $includeSelected, $includeChildren, $duplicates);
     }
 }
 public function testDiffedChangesTitle()
 {
     $page = new Page(array('Title' => 'My Title'));
     $page->write();
     $page->publish('Stage', 'Live');
     $page->Title = 'My Changed Title';
     $page->write();
     $page->publish('Stage', 'Live');
     $page->Title = 'My Unpublished Changed Title';
     $page->write();
     // Strip spaces from test output because they're not reliably maintained by the HTML Tidier
     $cleanDiffOutput = function ($val) {
         return str_replace(' ', '', strip_tags($val));
     };
     $this->assertContains(str_replace(' ', '', _t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Changed Title'), array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')), 'Detects published title changes');
     $this->assertNotContains(str_replace(' ', '', _t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Unpublished Changed Title'), array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')), 'Ignores unpublished title changes');
 }
 public function testCreateNewContent()
 {
     $this->logInWithPermission('CMS_ACCESS_CMSMain');
     $mid = Member::currentUserID();
     // create some content and make a change. When saving, it should be added to the current user's
     // active changeset
     $obj = new Page();
     $obj->Title = "New Page";
     $obj->write();
     // it should have a changeset now
     $cs1 = $obj->getCurrentChangeset();
     $this->assertNotNull($cs1);
     $obj->Title = "New Page Title";
     $obj->write();
     $cs1 = $obj->getCurrentChangeset();
     $this->assertNotNull($cs1);
     $this->assertEquals(1, $cs1->getItems()->Count());
     $this->assertEquals("Active", $cs1->Status);
 }
 public function testPageURL()
 {
     $page = new Page();
     $page->URLSegment = 'test';
     $page->write();
     $obj = new LinkFieldTest_DataObject();
     $obj->Link->setPageID($page->ID);
     $obj->write();
     $this->assertEquals($page->Link(), $obj->Link->URL);
 }
 public function setUp()
 {
     parent::setUp();
     for ($i = 0; $i < 100; $i++) {
         $page = new Page(array('title' => "Page {$i}"));
         $page->write();
         $page->publish('Stage', 'Live');
     }
     $sitemap = new SiteMapPage();
     $sitemap->Title = 'SiteMap';
     $sitemap->write();
 }
	function testCustomSearchFormClassesToTest() {
		FulltextSearchable::enable('File');
		
		$page = new Page();
		$page->URLSegment = 'whatever';
		$page->Content = 'oh really?';
		$page->write();
		$page->publish('Stage', 'Live'); 
		$controller = new ContentController($page);
		$form = $controller->SearchForm(); 
		
		if (get_class($form) == 'SearchForm') $this->assertEquals(array('File'), $form->getClassesToSearch());
	}
 public function setUp()
 {
     parent::setUp();
     // create 2 pages
     for ($i = 0; $i < 2; ++$i) {
         $page = new Page(array('Title' => "Page {$i}"));
         $page->write();
         $page->publish('Stage', 'Live');
     }
     // reset configuration for the test.
     Config::nest();
     Config::inst()->update('Foo', 'bar', 'Hello!');
 }
 protected function makePages($count, $depth, $prefix = "", $parentID = 0)
 {
     for ($i = 1; $i <= $count; $i++) {
         $page = new Page();
         $page->ParentID = $parentID;
         $page->Title = "Test page {$prefix}{$i}";
         $page->write();
         $page->publish('Stage', 'Live');
         echo "<li>Created '{$page->Title}'";
         if ($depth > 1) {
             $this->makePages($count, $depth - 1, $prefix . "{$i}.", $page->ID);
         }
     }
 }
 function testHighlighter()
 {
     $content = $this->highlight('<a href="[sitetree_link,id=123]" class="existing-class">link</a>');
     $this->assertEquals(substr_count($content, 'ss-broken'), 1, 'A ss-broken class is added to the broken link.');
     $this->assertEquals(substr_count($content, 'existing-class'), 1, 'Existing class is not removed.');
     $content = $this->highlight('<a href="[sitetree_link,id=123]">link</a>');
     $this->assertEquals(substr_count($content, 'ss-broken'), 1, 'ss-broken class is added to the broken link.');
     $otherPage = new Page();
     $otherPage->Content = '';
     $otherPage->write();
     $content = $this->highlight("<a href=\"[sitetree_link,id={$otherPage->ID}]\" class=\"existing-class ss-broken ss-broken\">link</a>");
     $this->assertEquals(substr_count($content, 'ss-broken'), 0, 'All ss-broken classes are removed from good link');
     $this->assertEquals(substr_count($content, 'existing-class'), 1, 'Existing class is not removed.');
 }
 function testBatchSetResetExpiry()
 {
     $oldRequest = $_REQUEST;
     $action = new BatchSetExpiry();
     $this->assertTrue(is_string($action->getActionTitle()));
     $this->assertTrue(is_string($action->getDoingText()));
     $this->assertTrue($action->getParameterFields() instanceof FieldSet);
     $this->logInAs($this->objFromFixture('Member', 'admin'));
     $page1 = new Page();
     $page1->write();
     $page1->openOrNewWorkflowRequest('WorkflowPublicationRequest');
     $page1ID = $page1->ID;
     $page2 = new Page();
     $page2->Content = '<a href="' . $page1->AbsoluteLink() . '">link here</a>';
     $page2->write();
     $page2ID = $page2->ID;
     $pages = new DataObjectSet();
     $pages->push($page1);
     $pages->push($page2);
     $this->assertEquals(array($page1->ID), $action->applicablePages($pages->column('ID')), 'applicableIds only returns pages with open requests');
     SS_Datetime::set_mock_now('2009-06-15 15:00:00');
     $_REQUEST['ExpiryDate_Batch'] = array('date' => '31/01/2010', 'time' => '3:00 pm');
     $_REQUEST['ajax'] = 1;
     // Test confirmation dialog
     $page1->BacklinkTracking()->add($page2);
     $confirmation = $action->confirmationDialog($pages->column('ID'));
     $this->assertTrue($confirmation['alert']);
     $action->run($pages);
     $page1 = DataObject::get_by_id('Page', $page1ID);
     $page2 = DataObject::get_by_id('Page', $page2ID);
     $this->assertEquals($page1->ExpiryDate, '2010-01-31 15:00:00');
     $this->assertNull($page2->openWorkflowRequest());
     $this->assertNull($page2->ExpiryDate);
     // Now test resetting
     $action = new BatchResetExpiry();
     $this->assertTrue(is_string($action->getActionTitle()));
     $this->assertTrue(is_string($action->getDoingText()));
     $pages = new DataObjectSet();
     $pages->push($page1);
     $pages->push($page2);
     $this->assertEquals(array($page1->ID), $action->applicablePages(array($page1->ID, $page2->ID)), 'applicableIds only returns pages with open requests');
     $action->run($pages);
     $page1 = DataObject::get_by_id('Page', $page1ID);
     $page2 = DataObject::get_by_id('Page', $page2ID);
     $this->assertNull($page1->openWorkflowRequest()->ExpiryDate);
     $this->assertNull($page2->openWorkflowRequest());
     $_REQUEST = $oldRequest;
     SS_Datetime::clear_mock_now();
 }
 function testTraverseRelations()
 {
     $exporter = new TestDataExporter();
     $pageParent = new Page();
     $pageParent->ID = 1;
     $pageParent->write();
     $pageChild = new Page();
     $pageChild->ID = 2;
     $pageChild->ParentID = 1;
     $pageChild->write();
     $queue = array();
     $buckets = array();
     $exporter->traverseRelations($pageChild, $buckets, $queue);
     $this->assertEquals($queue[0]->ID, 1, "Finds the Parent() and adds it to the queue for further processing");
 }
 public function testPublishActionWithFutureDates()
 {
     $action = new PublishItemWorkflowAction();
     $instance = new WorkflowInstance();
     $page = new Page();
     $page->Title = 'stuff';
     $page->DesiredPublishDate = '2020-02-01 00:00:00';
     $page->DesiredUnPublishDate = '2020-02-01 02:00:00';
     $page->write();
     $instance->TargetClass = $page->ClassName;
     $instance->TargetID = $page->ID;
     $action->execute($instance);
     $page = DataObject::get_by_id('Page', $page->ID);
     $this->assertTrue($page->PublishJobID > 0);
     $this->assertTrue($page->UnPublishJobID > 0);
 }
 public function testPublishAction()
 {
     $this->logInWithPermission();
     $action = new PublishItemWorkflowAction();
     $instance = new WorkflowInstance();
     $page = new Page();
     $page->Title = 'stuff';
     $page->write();
     $instance->TargetClass = 'Page';
     $instance->TargetID = $page->ID;
     $this->assertFalse($page->isPublished());
     //		$this->assertTrue($page->Status == 'New');
     $action->execute($instance);
     $page = DataObject::get_by_id('Page', $page->ID);
     $this->assertTrue($page->isPublished());
 }
 public function testStaticPublisherTheme()
 {
     // This will be the name of the default theme of this particular project
     $default_theme = Config::inst()->get('SSViewer', 'theme');
     $p1 = new Page();
     $p1->URLSegment = strtolower(__CLASS__) . '-page-1';
     $p1->HomepageForDomain = '';
     $p1->write();
     $p1->doPublish();
     $current_theme = Config::inst()->get('SSViewer', 'theme_enabled') ? Config::inst()->get('SSViewer', 'theme') : null;
     $this->assertEquals($current_theme, $default_theme, 'After a standard publication, the theme is correct');
     //We can set the static_publishing theme to something completely different:
     //Static publishing will use this one instead of the current_custom_theme if it is not false
     Config::inst()->update('StaticPublisher', 'static_publisher_theme', 'otherTheme');
     $current_theme = Config::inst()->get('StaticPublisher', 'static_publisher_theme');
     $this->assertNotEquals($current_theme, $default_theme, 'The static publisher theme overrides the custom theme');
 }
 public function testCanViewStage()
 {
     $page = new Page();
     $page->URLSegment = 'testpage';
     $page->write();
     $page->publish('Stage', 'Live');
     $response = $this->get('/testpage');
     $this->assertEquals($response->getStatusCode(), 200);
     $response = $this->get('/testpage/?stage=Live');
     $this->assertEquals($response->getStatusCode(), 200);
     $response = $this->get('/testpage/?stage=Stage');
     // should redirect to login
     $this->assertEquals($response->getStatusCode(), 302);
     $this->logInWithPermission('CMS_ACCESS_CMSMain');
     $response = $this->get('/testpage/?stage=Stage');
     $this->assertEquals($response->getStatusCode(), 200);
 }
 public function testDeepNestedURLs()
 {
     Config::inst()->update('SiteTree', 'nested_urls', true);
     $page = new Page();
     $page->URLSegment = 'base-page';
     $page->write();
     for ($i = 0; $i < 10; $i++) {
         $parentID = $page->ID;
         $page = new ContentControllerTest_Page();
         $page->ParentID = $parentID;
         $page->Title = "Page Level {$i}";
         $page->URLSegment = "level-{$i}";
         $page->write();
         $relativeLink = Director::makeRelative($page->Link());
         $this->assertEquals($page->Title, $this->get($relativeLink)->getBody());
     }
     SiteTree::config()->nested_urls = false;
 }
 public function testDeepNestedURLs()
 {
     SiteTree::enable_nested_urls();
     $page = new Page();
     $page->URLSegment = 'base-page';
     $page->write();
     for ($i = 0; $i < 10; $i++) {
         $parentID = $page->ID;
         $page = new ContentControllerTest_Page();
         $page->ParentID = $parentID;
         $page->Title = "Page Level {$i}";
         $page->URLSegment = "level-{$i}";
         $page->write();
         $relativeLink = Director::makeRelative($page->Link());
         $this->assertEquals($page->Title, $this->get($relativeLink)->getBody());
     }
     SiteTree::disable_nested_urls();
 }
 function testSubsiteVirtualPagesArentInappropriatelyPublished()
 {
     // Fixture
     $p = new Page();
     $p->Content = "test content";
     $p->write();
     $vp = new SubsitesVirtualPage();
     $vp->CopyContentFromID = $p->ID;
     $vp->write();
     // VP is oragne
     $this->assertTrue($vp->IsAddedToStage);
     // VP is still orange after we publish
     $p->doPublish();
     $this->fixVersionNumberCache($vp);
     $this->assertTrue($vp->IsAddedToStage);
     // A new VP created after P's initial construction
     $vp2 = new SubsitesVirtualPage();
     $vp2->CopyContentFromID = $p->ID;
     $vp2->write();
     $this->assertTrue($vp2->IsAddedToStage);
     // Also remains orange after a republish
     $p->Content = "new content";
     $p->write();
     $p->doPublish();
     $this->fixVersionNumberCache($vp2);
     $this->assertTrue($vp2->IsAddedToStage);
     // VP is now published
     $vp->doPublish();
     $this->fixVersionNumberCache($vp);
     $this->assertTrue($vp->ExistsOnLive);
     $this->assertFalse($vp->IsModifiedOnStage);
     // P edited, VP and P both go green
     $p->Content = "third content";
     $p->write();
     $this->fixVersionNumberCache($vp, $p);
     $this->assertTrue($p->IsModifiedOnStage);
     $this->assertTrue($vp->IsModifiedOnStage);
     // Publish, VP goes black
     $p->doPublish();
     $this->fixVersionNumberCache($vp);
     $this->assertTrue($vp->ExistsOnLive);
     $this->assertFalse($vp->IsModifiedOnStage);
 }
 function testNumChildren()
 {
     $this->assertEquals($this->objFromFixture('Page', 'page1')->numChildren(), 0);
     $this->assertEquals($this->objFromFixture('Page', 'page2')->numChildren(), 2);
     $this->assertEquals($this->objFromFixture('Page', 'page3')->numChildren(), 2);
     $this->assertEquals($this->objFromFixture('Page', 'page2a')->numChildren(), 2);
     $this->assertEquals($this->objFromFixture('Page', 'page2b')->numChildren(), 0);
     $this->assertEquals($this->objFromFixture('Page', 'page3a')->numChildren(), 2);
     $this->assertEquals($this->objFromFixture('Page', 'page3b')->numChildren(), 0);
     $page1 = $this->objFromFixture('Page', 'page1');
     $this->assertEquals($page1->numChildren(), 0);
     $page1Child1 = new Page();
     $page1Child1->ParentID = $page1->ID;
     $page1Child1->write();
     $this->assertEquals($page1->numChildren(false), 1, 'numChildren() caching can be disabled through method parameter');
     $page1Child2 = new Page();
     $page1Child2->ParentID = $page1->ID;
     $page1Child2->write();
     $page1->flushCache();
     $this->assertEquals($page1->numChildren(), 2, 'numChildren() caching can be disabled by flushCache()');
 }
 function testStaticPublisherTheme()
 {
     //This will be the name of the default theme of this particular project
     $default_theme = SSViewer::current_theme();
     $p1 = new Page();
     $p1->URLSegment = strtolower(__CLASS__) . '-page-1';
     $p1->HomepageForDomain = '';
     $p1->write();
     $p1->doPublish();
     $current_theme = SSViewer::current_custom_theme();
     $this->assertEquals($current_theme, $default_theme, 'After a standard publication, the theme is correct');
     //The CMS sometimes sets the theme to null.  Check that the $current_custom_theme is still the default
     SSViewer::set_theme(null);
     $current_theme = SSViewer::current_custom_theme();
     $this->assertEquals($current_theme, $default_theme, 'After a setting the theme to null, the default theme is correct');
     //We can set the static_publishing theme to something completely different:
     //Static publishing will use this one instead of the current_custom_theme if it is not false
     StaticPublisher::set_static_publisher_theme('otherTheme');
     $current_theme = StaticPublisher::static_publisher_theme();
     $this->assertNotEquals($current_theme, $default_theme, 'The static publisher theme overrides the custom theme');
 }
 function testStaticPublishing()
 {
     $this->logInWithPermission('ADMIN');
     $p1 = new Page();
     $p1->URLSegment = strtolower(__CLASS__) . '-page-1';
     $p1->HomepageForDomain = '';
     $p1->write();
     $p1->doPublish();
     $p2 = new Page();
     $p2->URLSegment = strtolower(__CLASS__) . '-page-2';
     $p2->HomepageForDomain = 'domain1';
     $p2->write();
     $p2->doPublish();
     $p3 = new Page();
     $p3->URLSegment = strtolower(__CLASS__) . '-page-3';
     $p3->HomepageForDomain = 'domain2,domain3';
     $p3->write();
     $p3->doPublish();
     $map = HomepageForDomainExtension::generate_homepage_domain_map();
     $this->assertEquals($map, array('domain1' => strtolower(__CLASS__) . '-page-2', 'domain2' => strtolower(__CLASS__) . '-page-3', 'domain3' => strtolower(__CLASS__) . '-page-3'), 'Homepage/domain map is correct when static publishing is enabled');
 }
	public function testCanViewStage() {
		$page = new Page();
		$page->URLSegment = 'testpage';
		$page->write();
		$page->publish('Stage', 'Live');
		
		$response = $this->get('/testpage');
		$this->assertEquals($response->getStatusCode(), 200, 'Doesnt require login for implicit live stage');
		
		$response = $this->get('/testpage/?stage=Live');
		$this->assertEquals($response->getStatusCode(), 200, 'Doesnt require login for explicit live stage');
		
		$response = $this->get('/testpage/?stage=Stage');
		// should redirect to login
		$this->assertEquals($response->getStatusCode(), 302, 'Redirects to login page when not logged in for draft stage');
		$this->assertContains('Security/login', $response->getHeader('Location'));
		
		$this->logInWithPermission('CMS_ACCESS_CMSMain');
		
		$response = $this->get('/testpage/?stage=Stage');
		$this->assertEquals($response->getStatusCode(), 200, 'Doesnt redirect to login, but shows page for authenticated user');
	}