diff options
Diffstat (limited to 'tests/lib/AppFramework/Http')
-rw-r--r-- | tests/lib/AppFramework/Http/DispatcherTest.php | 30 | ||||
-rw-r--r-- | tests/lib/AppFramework/Http/RequestTest.php | 104 | ||||
-rw-r--r-- | tests/lib/AppFramework/Http/StreamResponseTest.php | 12 |
3 files changed, 73 insertions, 73 deletions
diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php index 1c4dc067b5d..494f19a6d24 100644 --- a/tests/lib/AppFramework/Http/DispatcherTest.php +++ b/tests/lib/AppFramework/Http/DispatcherTest.php @@ -156,7 +156,7 @@ class DispatcherTest extends \Test\TestCase { ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod), $this->equalTo($exception)) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); } else { $this->middlewareDispatcher->expects($this->once()) ->method('afterException') @@ -173,51 +173,51 @@ class DispatcherTest extends \Test\TestCase { $this->equalTo($this->controllerMethod)); $this->controller->expects($this->once()) ->method($this->controllerMethod) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); } $this->response->expects($this->once()) ->method('render') - ->will($this->returnValue($out)); + ->willReturn($out); $this->response->expects($this->once()) ->method('getStatus') - ->will($this->returnValue(Http::STATUS_OK)); + ->willReturn(Http::STATUS_OK); $this->response->expects($this->once()) ->method('getLastModified') - ->will($this->returnValue($this->lastModified)); + ->willReturn($this->lastModified); $this->response->expects($this->once()) ->method('getETag') - ->will($this->returnValue($this->etag)); + ->willReturn($this->etag); $this->response->expects($this->once()) ->method('getHeaders') - ->will($this->returnValue($responseHeaders)); + ->willReturn($responseHeaders); $this->http->expects($this->once()) ->method('getStatusHeader') ->with($this->equalTo(Http::STATUS_OK), $this->equalTo($this->lastModified), $this->equalTo($this->etag)) - ->will($this->returnValue($httpHeaders)); + ->willReturn($httpHeaders); $this->middlewareDispatcher->expects($this->once()) ->method('afterController') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod), $this->equalTo($this->response)) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $this->middlewareDispatcher->expects($this->once()) ->method('afterController') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod), $this->equalTo($this->response)) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $this->middlewareDispatcher->expects($this->once()) ->method('beforeOutput') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod), $this->equalTo($out)) - ->will($this->returnValue($out)); + ->willReturn($out); } @@ -281,14 +281,14 @@ class DispatcherTest extends \Test\TestCase { ->method('beforeController'); $this->middlewareDispatcher->expects($this->once()) ->method('afterController') - ->will($this->returnCallback(function($a, $b, $in) { + ->willReturnCallback(function($a, $b, $in) { return $in; - })); + }); $this->middlewareDispatcher->expects($this->once()) ->method('beforeOutput') - ->will($this->returnCallback(function($a, $b, $in) { + ->willReturnCallback(function($a, $b, $in) { return $in; - })); + }); } diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php index be019050e1b..67fef79dcff 100644 --- a/tests/lib/AppFramework/Http/RequestTest.php +++ b/tests/lib/AppFramework/Http/RequestTest.php @@ -378,7 +378,7 @@ class RequestTest extends \Test\TestCase { $this->secureRandom->expects($this->once()) ->method('generate') ->with('20') - ->will($this->returnValue('GeneratedByOwnCloudItself')); + ->willReturn('GeneratedByOwnCloudItself'); $request = new Request( [], @@ -409,7 +409,7 @@ class RequestTest extends \Test\TestCase { ->expects($this->once()) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue([])); + ->willReturn([]); $request = new Request( [ @@ -433,12 +433,12 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['10.0.0.2'])); + ->willReturn(['10.0.0.2']); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('forwarded_for_headers') - ->will($this->returnValue([])); + ->willReturn([]); $request = new Request( [ @@ -462,12 +462,12 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['10.0.0.2'])); + ->willReturn(['10.0.0.2']); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('forwarded_for_headers') - ->will($this->returnValue(['HTTP_X_FORWARDED'])); + ->willReturn(['HTTP_X_FORWARDED']); $request = new Request( [ @@ -491,12 +491,12 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['2001:db8:85a3:8d3:1319:8a2e:370:7348'])); + ->willReturn(['2001:db8:85a3:8d3:1319:8a2e:370:7348']); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('forwarded_for_headers') - ->will($this->returnValue(['HTTP_X_FORWARDED'])); + ->willReturn(['HTTP_X_FORWARDED']); $request = new Request( [ @@ -520,16 +520,16 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['10.0.0.2'])); + ->willReturn(['10.0.0.2']); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('forwarded_for_headers') - ->will($this->returnValue([ + ->willReturn([ 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED' - ])); + ]); $request = new Request( [ @@ -553,16 +553,16 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['2001:db8:85a3:8d3:1319:8a2e:370:7348'])); + ->willReturn(['2001:db8:85a3:8d3:1319:8a2e:370:7348']); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('forwarded_for_headers') - ->will($this->returnValue([ + ->willReturn([ 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED' - ])); + ]); $request = new Request( [ @@ -586,12 +586,12 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['192.168.2.0/24'])); + ->willReturn(['192.168.2.0/24']); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('forwarded_for_headers') - ->will($this->returnValue(['HTTP_X_FORWARDED_FOR'])); + ->willReturn(['HTTP_X_FORWARDED_FOR']); $request = new Request( [ @@ -615,7 +615,7 @@ class RequestTest extends \Test\TestCase { ->expects($this->once()) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['192.168.2.0/24'])); + ->willReturn(['192.168.2.0/24']); $request = new Request( [ @@ -690,17 +690,17 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('overwriteprotocol') - ->will($this->returnValue('customProtocol')); + ->willReturn('customProtocol'); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('overwritecondaddr') - ->will($this->returnValue('')); + ->willReturn(''); $this->config ->expects($this->at(2)) ->method('getSystemValue') ->with('overwriteprotocol') - ->will($this->returnValue('customProtocol')); + ->willReturn('customProtocol'); $request = new Request( [], @@ -716,13 +716,13 @@ class RequestTest extends \Test\TestCase { public function testGetServerProtocolWithProtoValid() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; } return $default; - })); + }); $requestHttps = new Request( [ @@ -757,9 +757,9 @@ class RequestTest extends \Test\TestCase { public function testGetServerProtocolWithHttpsServerValueOn() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function($key, $default) { return $default; - })); + }); $request = new Request( [ @@ -778,9 +778,9 @@ class RequestTest extends \Test\TestCase { public function testGetServerProtocolWithHttpsServerValueOff() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function($key, $default) { return $default; - })); + }); $request = new Request( [ @@ -799,9 +799,9 @@ class RequestTest extends \Test\TestCase { public function testGetServerProtocolWithHttpsServerValueEmpty() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function($key, $default) { return $default; - })); + }); $request = new Request( [ @@ -820,9 +820,9 @@ class RequestTest extends \Test\TestCase { public function testGetServerProtocolDefault() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function($key, $default) { return $default; - })); + }); $request = new Request( [], @@ -837,13 +837,13 @@ class RequestTest extends \Test\TestCase { public function testGetServerProtocolBehindLoadBalancers() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; } return $default; - })); + }); $request = new Request( [ @@ -1059,13 +1059,13 @@ class RequestTest extends \Test\TestCase { public function testInsecureServerHostHttpFromForwardedHeaderSingle() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; } return $default; - })); + }); $request = new Request( [ @@ -1088,13 +1088,13 @@ class RequestTest extends \Test\TestCase { public function testInsecureServerHostHttpFromForwardedHeaderStacked() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; } return $default; - })); + }); $request = new Request( [ @@ -1117,7 +1117,7 @@ class RequestTest extends \Test\TestCase { public function testGetServerHostWithOverwriteHost() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function($key, $default) { if ($key === 'overwritecondaddr') { return ''; } else if ($key === 'overwritehost') { @@ -1125,7 +1125,7 @@ class RequestTest extends \Test\TestCase { } return $default; - })); + }); $request = new Request( [], @@ -1141,7 +1141,7 @@ class RequestTest extends \Test\TestCase { public function testGetServerHostWithTrustedDomain() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; } else if ($key === 'trusted_domains') { @@ -1149,7 +1149,7 @@ class RequestTest extends \Test\TestCase { } return $default; - })); + }); $request = new Request( [ @@ -1170,7 +1170,7 @@ class RequestTest extends \Test\TestCase { public function testGetServerHostWithUntrustedDomain() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; } else if ($key === 'trusted_domains') { @@ -1178,7 +1178,7 @@ class RequestTest extends \Test\TestCase { } return $default; - })); + }); $request = new Request( [ @@ -1199,12 +1199,12 @@ class RequestTest extends \Test\TestCase { public function testGetServerHostWithNoTrustedDomain() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; } return $default; - })); + }); $request = new Request( [ @@ -1273,7 +1273,7 @@ class RequestTest extends \Test\TestCase { ->expects($this->once()) ->method('getSystemValue') ->with('overwritehost') - ->will($this->returnValue('')); + ->willReturn(''); $request = new Request( [], $this->secureRandom, @@ -1290,17 +1290,17 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('overwritehost') - ->will($this->returnValue('www.owncloud.org')); + ->willReturn('www.owncloud.org'); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('overwritecondaddr') - ->will($this->returnValue('')); + ->willReturn(''); $this->config ->expects($this->at(2)) ->method('getSystemValue') ->with('overwritehost') - ->will($this->returnValue('www.owncloud.org')); + ->willReturn('www.owncloud.org'); $request = new Request( [], @@ -1485,7 +1485,7 @@ class RequestTest extends \Test\TestCase { ->expects($this->once()) ->method('getSystemValue') ->with('overwritewebroot') - ->will($this->returnValue('')); + ->willReturn(''); $request = new Request( [ @@ -1517,12 +1517,12 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('overwritewebroot') - ->will($this->returnValue($overwriteWebRoot)); + ->willReturn($overwriteWebRoot); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('overwritecondaddr') - ->will($this->returnValue($overwriteCondAddr)); + ->willReturn($overwriteCondAddr); $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') ->setMethods(['getScriptName']) @@ -1542,7 +1542,7 @@ class RequestTest extends \Test\TestCase { $request ->expects($this->once()) ->method('getScriptName') - ->will($this->returnValue('/scriptname.php')); + ->willReturn('/scriptname.php'); $this->assertSame($expectedUri, $request->getRequestUri()); } diff --git a/tests/lib/AppFramework/Http/StreamResponseTest.php b/tests/lib/AppFramework/Http/StreamResponseTest.php index ef7132013b6..b66d9c5ed1d 100644 --- a/tests/lib/AppFramework/Http/StreamResponseTest.php +++ b/tests/lib/AppFramework/Http/StreamResponseTest.php @@ -44,7 +44,7 @@ class StreamResponseTest extends \Test\TestCase { $path = __FILE__; $this->output->expects($this->once()) ->method('getHttpResponseCode') - ->will($this->returnValue(Http::STATUS_NOT_MODIFIED)); + ->willReturn(Http::STATUS_NOT_MODIFIED); $this->output->expects($this->never()) ->method('setReadfile'); $response = new StreamResponse($path); @@ -56,11 +56,11 @@ class StreamResponseTest extends \Test\TestCase { $path = __FILE__; $this->output->expects($this->once()) ->method('getHttpResponseCode') - ->will($this->returnValue(Http::STATUS_OK)); + ->willReturn(Http::STATUS_OK); $this->output->expects($this->once()) ->method('setReadfile') ->with($this->equalTo($path)) - ->will($this->returnValue(true)); + ->willReturn(true); $response = new StreamResponse($path); $response->callback($this->output); @@ -70,7 +70,7 @@ class StreamResponseTest extends \Test\TestCase { $path = __FILE__ . 'test'; $this->output->expects($this->once()) ->method('getHttpResponseCode') - ->will($this->returnValue(Http::STATUS_OK)); + ->willReturn(Http::STATUS_OK); $this->output->expects($this->never()) ->method('setReadfile'); $this->output->expects($this->once()) @@ -85,10 +85,10 @@ class StreamResponseTest extends \Test\TestCase { $path = __FILE__; $this->output->expects($this->once()) ->method('getHttpResponseCode') - ->will($this->returnValue(Http::STATUS_OK)); + ->willReturn(Http::STATUS_OK); $this->output->expects($this->once()) ->method('setReadfile') - ->will($this->returnValue(false)); + ->willReturn(false); $this->output->expects($this->once()) ->method('setHttpResponseCode') ->with($this->equalTo(Http::STATUS_BAD_REQUEST)); |