setupRouter example

->getMock();
    $this->router->expects($this->once())
      ->method('matchRequest')
      ->willReturn([RouteObjectInterface::ROUTE_OBJECT => $this->route]);
    $this->accessAwareRouter = new AccessAwareRouter($this->router, $this->accessManager, $this->currentUser);
  }

  /** * Tests the matchRequest() function for access allowed. */
  public function testMatchRequestAllowed() {
    $this->setupRouter();
    $request = new Request();
    $access_result = AccessResult::allowed();
    $this->accessManager->expects($this->once())
      ->method('checkRequest')
      ->with($request)
      ->willReturn($access_result);
    $parameters = $this->accessAwareRouter->matchRequest($request);
    $expected = [
      RouteObjectInterface::ROUTE_OBJECT => $this->route,
      AccessAwareRouterInterface::ACCESS_RESULT => $access_result,
    ];
    
Home | Imprint | This part of the site doesn't use cookies.