Example #1
0
 public function testGetTitleReturnsPageTitle()
 {
     $page = $this->getMock(Page::class, ['getTitle']);
     $page->expects($this->any())->method('getTitle')->will($this->returnValue('test'));
     PageFacade::shouldReceive('findByUri')->with('test')->andReturn($page);
     $link = new Link('test');
     $this->assertEquals('test', $link->getTitle());
 }
Example #2
0
 public static function factory($link)
 {
     $link = preg_replace('|^https?://' . Request::getHttpHost() . '|', '', $link);
     if (is_int($link) || ctype_digit($link) || substr($link, 0, 1) == '/') {
         $internal = new Internal($link);
         // If it's not a valid CMS URL then it's a relative URL which isn't CMS managed so treat it as an external URL.
         return $internal->isValidPage() ? $internal : new External($link);
     } else {
         return new External($link);
     }
 }