/**
  * Tests to make sure short codes get translated to full paths.
  *
  */
 public function testRedirectingMapping()
 {
     DocumentationPermalinks::add(array('foo' => 'en/framework/subfolder/foo', 'bar' => 'en/cms/bar'));
     $this->autoFollowRedirection = false;
     $v = new DocumentationViewer();
     $response = $v->handleRequest(new SS_HTTPRequest('GET', 'foo'), DataModel::inst());
     $this->assertEquals('301', $response->getStatusCode());
     $this->assertContains('en/framework/subfolder/foo', $response->getHeader('Location'));
 }
 /**
  * Tests to make sure short codes get translated to full paths
  */
 function testRedirectingMapping()
 {
     // testing the viewer class but clearer here
     DocumentationPermalinks::add(array('foo' => 'current/en/sapphire/subfolder/foo', 'bar' => 'current/en/cms/bar'));
     $this->autoFollowRedirection = false;
     $v = new DocumentationViewer();
     $response = $v->handleRequest(new SS_HTTPRequest('GET', 'foo'));
     $this->assertEquals('301', $response->getStatusCode());
     $this->assertContains('current/en/sapphire/subfolder/foo', $response->getHeader('Location'));
 }
 function testVersionWarning()
 {
     $v = new DocumentationViewer();
     // the current version is set to 2.4, no notice should be shown on that page
     $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4'));
     $this->assertFalse($v->VersionWarning());
     // 2.3 is an older release, hitting that should return us an outdated flag
     $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.3'));
     $warn = $v->VersionWarning();
     $this->assertTrue($warn->OutdatedRelease);
     $this->assertNull($warn->FutureRelease);
     // 3.0 is a future release
     $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/3.0'));
     $warn = $v->VersionWarning();
     $this->assertNull($warn->OutdatedRelease);
     $this->assertTrue($warn->FutureRelease);
 }
 function testGetModulePages()
 {
     $v = new DocumentationViewer();
     $response = $v->handleRequest(new SS_HTTPRequest('GET', '2.4/en/DocumentationViewerTests/subfolder/'));
     $pages = $v->getModulePages();
     $this->assertEquals(array('index', 'subfolder', 'test'), $pages->column('Filename'));
     $this->assertEquals(array('link', 'current', 'link'), $pages->column('LinkingMode'));
     $links = $pages->column('Link');
     $this->assertStringEndsWith('2.4/en/DocumentationViewerTests/', $links[0]);
     $this->assertStringEndsWith('2.4/en/DocumentationViewerTests/subfolder/', $links[1]);
     $this->assertStringEndsWith('2.4/en/DocumentationViewerTests/test/', $links[2]);
     // Children
     $pagesArr = $pages->toArray();
     $child1 = $pagesArr[0];
     $this->assertFalse($child1->Children);
     $child2 = $pagesArr[1];
     $this->assertType('DataObjectSet', $child2->Children);
     $this->assertEquals(array('subpage', 'subsubfolder'), $child2->Children->column('Filename'));
     $child2Links = $child2->Children->column('Link');
     $this->assertStringEndsWith('2.4/en/DocumentationViewerTests/subfolder/subpage/', $child2Links[0]);
     $this->assertStringEndsWith('2.4/en/DocumentationViewerTests/subfolder/subsubfolder/', $child2Links[1]);
 }
 public function testGetLanguage()
 {
     $v = new DocumentationViewer();
     $response = $v->handleRequest(new SS_HTTPRequest('GET', 'en/doc_test/2.3/'), DataModel::inst());
     $this->assertEquals('en', $v->getLanguage());
     $response = $v->handleRequest(new SS_HTTPRequest('GET', 'en/doc_test/2.3/subfolder/subsubfolder/subsubpage/'), DataModel::inst());
     $this->assertEquals('en', $v->getLanguage());
 }