Пример #1
0
 /**
  * @test
  * @expectedException \InvalidArgumentException
  */
 public function willThrowAnExceptionWhenProvidingNotMatchingParams()
 {
     $paramValue = 'abc';
     $matcher = $this->createMock(Matcher::class);
     $matcher->expects($this->once())->method('__invoke')->with($paramValue)->will($this->returnValue(false));
     $this->router->addRoute(RouteBuilder::route()->get('/company/[:companyId]')->to('companyAction')->ifMatches('companyId', $matcher)->build());
     $this->router->generateUri('companyAction', ['companyId' => $paramValue]);
 }
Пример #2
0
 /**
  * @test
  */
 public function routeParamsOverwriteQueryParams()
 {
     $this->request = new ServerRequest([], [], '/user/123', 'GET');
     $this->request = $this->request->withQueryParams(['userId' => '999']);
     $this->request = $this->router->match($this->request);
     $targetRequestAttribute = $this->router->getTargetRequestAttribute();
     $queryParams = $this->request->getQueryParams();
     $this->assertTrue(isset($queryParams['userId']));
     $this->assertSame('123', $queryParams['userId']);
 }