Пример #1
0
 /**
  * Test link
  *
  * @return void
  */
 public function testLinkAuthorized()
 {
     $view = new View();
     $eventManagerMock = $this->getMockBuilder('Cake\\Event\\EventManager')->setMethods(['dispatch'])->getMock();
     $view->eventManager($eventManagerMock);
     $this->AuthLink = new AuthLinkHelper($view);
     $result = new Event('dispatch-result');
     $result->result = true;
     $eventManagerMock->expects($this->once())->method('dispatch')->will($this->returnValue($result));
     $link = $this->AuthLink->link('title', '/', ['before' => 'before_', 'after' => '_after', 'class' => 'link-class']);
     $this->assertSame('before_<a href="/" class="link-class">title</a>_after', $link);
 }
Пример #2
0
 /**
  * Test link
  *
  * @return void
  */
 public function testLinkAuthorizedAllowedFalse()
 {
     $view = new View();
     $eventManagerMock = $this->getMockBuilder('Cake\\Event\\EventManager')->setMethods(['dispatch'])->getMock();
     $view->eventManager($eventManagerMock);
     $this->AuthLink = new AuthLinkHelper($view);
     $result = new Event('dispatch-result');
     $eventManagerMock->expects($this->never())->method('dispatch');
     $link = $this->AuthLink->link('title', '/', ['allowed' => false, 'before' => 'before_', 'after' => '_after', 'class' => 'link-class']);
     $this->assertFalse($link);
 }