Neos\Flow\Mvc\Routing\Route::setHttpMethods PHP Метод

setHttpMethods() публичный Метод

If empty all HTTP verbs are accepted
public setHttpMethods ( array $httpMethods ) : void
$httpMethods array non-associative array in the format array('GET', 'POST', ...)
Результат void
    public function setHttpMethods(array $httpMethods)
    {
        $this->httpMethods = $httpMethods;
    }

Usage Example

 /**
  * @test
  */
 public function routeMatchesIfRequestMethodIsAccepted()
 {
     $this->route->setUriPattern('');
     $this->route->setHttpMethods(['POST', 'PUT']);
     /** @var Request|\PHPUnit_Framework_MockObject_MockObject $mockHttpRequest */
     $mockHttpRequest = $this->getMockBuilder(Http\Request::class)->disableOriginalConstructor()->getMock();
     $mockUri = $this->getMockBuilder(Http\Uri::class)->disableOriginalConstructor()->getMock();
     $mockUri->expects($this->any())->method('getPath')->will($this->returnValue('/'));
     $mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($mockUri));
     $mockBaseUri = $this->getMockBuilder(Http\Uri::class)->disableOriginalConstructor()->getMock();
     $mockBaseUri->expects($this->any())->method('getPath')->will($this->returnValue('/'));
     $mockHttpRequest->expects($this->any())->method('getBaseUri')->will($this->returnValue($mockBaseUri));
     $mockHttpRequest->expects($this->atLeastOnce())->method('getMethod')->will($this->returnValue('PUT'));
     $this->assertTrue($this->route->matches($mockHttpRequest), 'Route should match PUT requests if POST and PUT requests are accepted.');
 }
All Usage Examples Of Neos\Flow\Mvc\Routing\Route::setHttpMethods