aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/AppFramework/Http
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/AppFramework/Http')
-rw-r--r--tests/lib/AppFramework/Http/DataResponseTest.php14
-rw-r--r--tests/lib/AppFramework/Http/DispatcherTest.php18
-rw-r--r--tests/lib/AppFramework/Http/HttpTest.php12
-rw-r--r--tests/lib/AppFramework/Http/JSONResponseTest.php12
-rw-r--r--tests/lib/AppFramework/Http/RequestStream.php4
-rw-r--r--tests/lib/AppFramework/Http/RequestTest.php86
-rw-r--r--tests/lib/AppFramework/Http/ResponseTest.php62
-rw-r--r--tests/lib/AppFramework/Http/TemplateResponseTest.php14
8 files changed, 111 insertions, 111 deletions
diff --git a/tests/lib/AppFramework/Http/DataResponseTest.php b/tests/lib/AppFramework/Http/DataResponseTest.php
index b629c6d385e..7af11807d87 100644
--- a/tests/lib/AppFramework/Http/DataResponseTest.php
+++ b/tests/lib/AppFramework/Http/DataResponseTest.php
@@ -41,15 +41,15 @@ class DataResponseTest extends \Test\TestCase {
public function testSetData() {
- $params = array('hi', 'yo');
+ $params = ['hi', 'yo'];
$this->response->setData($params);
- $this->assertEquals(array('hi', 'yo'), $this->response->getData());
+ $this->assertEquals(['hi', 'yo'], $this->response->getData());
}
public function testConstructorAllowsToSetData() {
- $data = array('hi');
+ $data = ['hi'];
$code = 300;
$response = new DataResponse($data, $code);
@@ -59,9 +59,9 @@ class DataResponseTest extends \Test\TestCase {
public function testConstructorAllowsToSetHeaders() {
- $data = array('hi');
+ $data = ['hi'];
$code = 300;
- $headers = array('test' => 'something');
+ $headers = ['test' => 'something'];
$response = new DataResponse($data, $code, $headers);
$expectedHeaders = [
@@ -78,12 +78,12 @@ class DataResponseTest extends \Test\TestCase {
public function testChainability() {
- $params = array('hi', 'yo');
+ $params = ['hi', 'yo'];
$this->response->setData($params)
->setStatus(Http::STATUS_NOT_FOUND);
$this->assertEquals(Http::STATUS_NOT_FOUND, $this->response->getStatus());
- $this->assertEquals(array('hi', 'yo'), $this->response->getData());
+ $this->assertEquals(['hi', 'yo'], $this->response->getData());
}
diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php
index 494f19a6d24..b6b43d4a5d3 100644
--- a/tests/lib/AppFramework/Http/DispatcherTest.php
+++ b/tests/lib/AppFramework/Http/DispatcherTest.php
@@ -52,9 +52,9 @@ class TestController extends Controller {
*/
public function exec($int, $bool, $test=4, $test2=1) {
$this->registerResponder('text', function($in) {
- return new JSONResponse(array('text' => $in));
+ return new JSONResponse(['text' => $in]);
});
- return array($int, $bool, $test, $test2);
+ return [$int, $bool, $test, $test2];
}
@@ -66,9 +66,9 @@ class TestController extends Controller {
* @return DataResponse
*/
public function execDataResponse($int, $bool, $test=4, $test2=1) {
- return new DataResponse(array(
- 'text' => array($int, $bool, $test, $test2)
- ));
+ return new DataResponse([
+ 'text' => [$int, $bool, $test, $test2]
+ ]);
}
}
@@ -140,7 +140,7 @@ class DispatcherTest extends \Test\TestCase {
* @param string $httpHeaders
*/
private function setMiddlewareExpectations($out=null,
- $httpHeaders=null, $responseHeaders=array(),
+ $httpHeaders=null, $responseHeaders=[],
$ex=false, $catchEx=true) {
if($ex) {
@@ -226,7 +226,7 @@ class DispatcherTest extends \Test\TestCase {
$response = $this->dispatcher->dispatch($this->controller, $this->controllerMethod);
$this->assertNull($response[0]);
- $this->assertEquals(array(), $response[1]);
+ $this->assertEquals([], $response[1]);
$this->assertNull($response[2]);
}
@@ -234,7 +234,7 @@ class DispatcherTest extends \Test\TestCase {
public function testHeadersAndOutputAreReturned(){
$out = 'yo';
$httpHeaders = 'Http';
- $responseHeaders = array('hell' => 'yeah');
+ $responseHeaders = ['hell' => 'yeah'];
$this->setMiddlewareExpectations($out, $httpHeaders, $responseHeaders);
$response = $this->dispatcher->dispatch($this->controller,
@@ -249,7 +249,7 @@ class DispatcherTest extends \Test\TestCase {
public function testExceptionCallsAfterException() {
$out = 'yo';
$httpHeaders = 'Http';
- $responseHeaders = array('hell' => 'yeah');
+ $responseHeaders = ['hell' => 'yeah'];
$this->setMiddlewareExpectations($out, $httpHeaders, $responseHeaders, true);
$response = $this->dispatcher->dispatch($this->controller,
diff --git a/tests/lib/AppFramework/Http/HttpTest.php b/tests/lib/AppFramework/Http/HttpTest.php
index 79c03ce1ab0..14097a2a581 100644
--- a/tests/lib/AppFramework/Http/HttpTest.php
+++ b/tests/lib/AppFramework/Http/HttpTest.php
@@ -37,7 +37,7 @@ class HttpTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
- $this->server = array();
+ $this->server = [];
$this->http = new Http($this->server);
}
@@ -56,7 +56,7 @@ class HttpTest extends \Test\TestCase {
public function testEtagMatchReturnsNotModified() {
- $http = new Http(array('HTTP_IF_NONE_MATCH' => 'hi'));
+ $http = new Http(['HTTP_IF_NONE_MATCH' => 'hi']);
$header = $http->getStatusHeader(Http::STATUS_OK, null, 'hi');
$this->assertEquals('HTTP/1.1 304 Not Modified', $header);
@@ -64,7 +64,7 @@ class HttpTest extends \Test\TestCase {
public function testQuotedEtagMatchReturnsNotModified() {
- $http = new Http(array('HTTP_IF_NONE_MATCH' => '"hi"'));
+ $http = new Http(['HTTP_IF_NONE_MATCH' => '"hi"']);
$header = $http->getStatusHeader(Http::STATUS_OK, null, 'hi');
$this->assertEquals('HTTP/1.1 304 Not Modified', $header);
@@ -76,8 +76,8 @@ class HttpTest extends \Test\TestCase {
$dateTime->setTimestamp('12');
$http = new Http(
- array(
- 'HTTP_IF_MODIFIED_SINCE' => 'Thu, 01 Jan 1970 00:00:12 +0000')
+ [
+ 'HTTP_IF_MODIFIED_SINCE' => 'Thu, 01 Jan 1970 00:00:12 +0000']
);
$header = $http->getStatusHeader(Http::STATUS_OK, $dateTime);
@@ -87,7 +87,7 @@ class HttpTest extends \Test\TestCase {
public function testTempRedirectBecomesFoundInHttp10() {
- $http = new Http(array(), 'HTTP/1.0');
+ $http = new Http([], 'HTTP/1.0');
$header = $http->getStatusHeader(Http::STATUS_TEMPORARY_REDIRECT);
$this->assertEquals('HTTP/1.0 302 Found', $header);
diff --git a/tests/lib/AppFramework/Http/JSONResponseTest.php b/tests/lib/AppFramework/Http/JSONResponseTest.php
index 95d2e2a0a4c..2a0978db62a 100644
--- a/tests/lib/AppFramework/Http/JSONResponseTest.php
+++ b/tests/lib/AppFramework/Http/JSONResponseTest.php
@@ -49,15 +49,15 @@ class JSONResponseTest extends \Test\TestCase {
public function testSetData() {
- $params = array('hi', 'yo');
+ $params = ['hi', 'yo'];
$this->json->setData($params);
- $this->assertEquals(array('hi', 'yo'), $this->json->getData());
+ $this->assertEquals(['hi', 'yo'], $this->json->getData());
}
public function testSetRender() {
- $params = array('test' => 'hi');
+ $params = ['test' => 'hi'];
$this->json->setData($params);
$expected = '{"test":"hi"}';
@@ -100,7 +100,7 @@ class JSONResponseTest extends \Test\TestCase {
}
public function testConstructorAllowsToSetData() {
- $data = array('hi');
+ $data = ['hi'];
$code = 300;
$response = new JSONResponse($data, $code);
@@ -110,12 +110,12 @@ class JSONResponseTest extends \Test\TestCase {
}
public function testChainability() {
- $params = array('hi', 'yo');
+ $params = ['hi', 'yo'];
$this->json->setData($params)
->setStatus(Http::STATUS_NOT_FOUND);
$this->assertEquals(Http::STATUS_NOT_FOUND, $this->json->getStatus());
- $this->assertEquals(array('hi', 'yo'), $this->json->getData());
+ $this->assertEquals(['hi', 'yo'], $this->json->getData());
}
}
diff --git a/tests/lib/AppFramework/Http/RequestStream.php b/tests/lib/AppFramework/Http/RequestStream.php
index 8f6dffd4e91..97951ea4b9f 100644
--- a/tests/lib/AppFramework/Http/RequestStream.php
+++ b/tests/lib/AppFramework/Http/RequestStream.php
@@ -77,7 +77,7 @@ class RequestStream {
public function stream_stat() {
$size = strlen($GLOBALS[$this->varname]);
$time = time();
- $data = array(
+ $data = [
'dev' => 0,
'ino' => 0,
'mode' => 0777,
@@ -91,7 +91,7 @@ class RequestStream {
'ctime' => $time,
'blksize' => -1,
'blocks' => -1,
- );
+ ];
return array_values($data) + $data;
//return false;
}
diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php
index 67fef79dcff..8f7c26cc952 100644
--- a/tests/lib/AppFramework/Http/RequestTest.php
+++ b/tests/lib/AppFramework/Http/RequestTest.php
@@ -51,10 +51,10 @@ class RequestTest extends \Test\TestCase {
}
public function testRequestAccessors() {
- $vars = array(
- 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
+ $vars = [
+ 'get' => ['name' => 'John Q. Public', 'nickname' => 'Joey'],
'method' => 'GET',
- );
+ ];
$request = new Request(
$vars,
@@ -82,12 +82,12 @@ class RequestTest extends \Test\TestCase {
// urlParams has precedence over POST which has precedence over GET
public function testPrecedence() {
- $vars = array(
- 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
- 'post' => array('name' => 'Jane Doe', 'nickname' => 'Janey'),
- 'urlParams' => array('user' => 'jw', 'name' => 'Johnny Weissmüller'),
+ $vars = [
+ 'get' => ['name' => 'John Q. Public', 'nickname' => 'Joey'],
+ 'post' => ['name' => 'Jane Doe', 'nickname' => 'Janey'],
+ 'urlParams' => ['user' => 'jw', 'name' => 'Johnny Weissmüller'],
'method' => 'GET'
- );
+ ];
$request = new Request(
$vars,
@@ -107,10 +107,10 @@ class RequestTest extends \Test\TestCase {
public function testImmutableArrayAccess() {
$this->expectException(\RuntimeException::class);
- $vars = array(
- 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
+ $vars = [
+ 'get' => ['name' => 'John Q. Public', 'nickname' => 'Joey'],
'method' => 'GET'
- );
+ ];
$request = new Request(
$vars,
@@ -127,10 +127,10 @@ class RequestTest extends \Test\TestCase {
public function testImmutableMagicAccess() {
$this->expectException(\RuntimeException::class);
- $vars = array(
- 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
+ $vars = [
+ 'get' => ['name' => 'John Q. Public', 'nickname' => 'Joey'],
'method' => 'GET'
- );
+ ];
$request = new Request(
$vars,
@@ -147,10 +147,10 @@ class RequestTest extends \Test\TestCase {
public function testGetTheMethodRight() {
$this->expectException(\LogicException::class);
- $vars = array(
- 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
+ $vars = [
+ 'get' => ['name' => 'John Q. Public', 'nickname' => 'Joey'],
'method' => 'GET',
- );
+ ];
$request = new Request(
$vars,
@@ -164,10 +164,10 @@ class RequestTest extends \Test\TestCase {
}
public function testTheMethodIsRight() {
- $vars = array(
- 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
+ $vars = [
+ 'get' => ['name' => 'John Q. Public', 'nickname' => 'Joey'],
'method' => 'GET',
- );
+ ];
$request = new Request(
$vars,
@@ -186,10 +186,10 @@ class RequestTest extends \Test\TestCase {
public function testJsonPost() {
global $data;
$data = '{"name": "John Q. Public", "nickname": "Joey"}';
- $vars = array(
+ $vars = [
'method' => 'POST',
- 'server' => array('CONTENT_TYPE' => 'application/json; utf-8')
- );
+ 'server' => ['CONTENT_TYPE' => 'application/json; utf-8']
+ ];
$request = new Request(
$vars,
@@ -210,10 +210,10 @@ class RequestTest extends \Test\TestCase {
public function testNotJsonPost() {
global $data;
$data = 'this is not valid json';
- $vars = array(
+ $vars = [
'method' => 'POST',
- 'server' => array('CONTENT_TYPE' => 'application/json; utf-8')
- );
+ 'server' => ['CONTENT_TYPE' => 'application/json; utf-8']
+ ];
$request = new Request(
$vars,
@@ -230,12 +230,12 @@ class RequestTest extends \Test\TestCase {
public function testPatch() {
global $data;
- $data = http_build_query(array('name' => 'John Q. Public', 'nickname' => 'Joey'), '', '&');
+ $data = http_build_query(['name' => 'John Q. Public', 'nickname' => 'Joey'], '', '&');
- $vars = array(
+ $vars = [
'method' => 'PATCH',
- 'server' => array('CONTENT_TYPE' => 'application/x-www-form-urlencoded'),
- );
+ 'server' => ['CONTENT_TYPE' => 'application/x-www-form-urlencoded'],
+ ];
$request = new Request(
$vars,
@@ -257,10 +257,10 @@ class RequestTest extends \Test\TestCase {
// PUT content
$data = '{"name": "John Q. Public", "nickname": "Joey"}';
- $vars = array(
+ $vars = [
'method' => 'PUT',
- 'server' => array('CONTENT_TYPE' => 'application/json; utf-8'),
- );
+ 'server' => ['CONTENT_TYPE' => 'application/json; utf-8'],
+ ];
$request = new Request(
$vars,
@@ -278,10 +278,10 @@ class RequestTest extends \Test\TestCase {
// PATCH content
$data = '{"name": "John Q. Public", "nickname": null}';
- $vars = array(
+ $vars = [
'method' => 'PATCH',
- 'server' => array('CONTENT_TYPE' => 'application/json; utf-8'),
- );
+ 'server' => ['CONTENT_TYPE' => 'application/json; utf-8'],
+ ];
$request = new Request(
$vars,
@@ -302,14 +302,14 @@ class RequestTest extends \Test\TestCase {
global $data;
$data = file_get_contents(__DIR__ . '/../../../data/testimage.png');
- $vars = array(
+ $vars = [
'put' => $data,
'method' => 'PUT',
'server' => [
'CONTENT_TYPE' => 'image/png',
'CONTENT_LENGTH' => (string)strlen($data)
],
- );
+ ];
$request = new Request(
$vars,
@@ -335,11 +335,11 @@ class RequestTest extends \Test\TestCase {
public function testSetUrlParameters() {
- $vars = array(
- 'post' => array(),
+ $vars = [
+ 'post' => [],
'method' => 'POST',
- 'urlParams' => array('id' => '2'),
- );
+ 'urlParams' => ['id' => '2'],
+ ];
$request = new Request(
$vars,
@@ -349,7 +349,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $newParams = array('id' => '3', 'test' => 'test2');
+ $newParams = ['id' => '3', 'test' => 'test2'];
$request->setUrlParameters($newParams);
$this->assertSame('test2', $request->getParam('test'));
$this->assertEquals('3', $request->getParam('id'));
diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php
index 3d76d24496d..86a909b7688 100644
--- a/tests/lib/AppFramework/Http/ResponseTest.php
+++ b/tests/lib/AppFramework/Http/ResponseTest.php
@@ -49,11 +49,11 @@ class ResponseTest extends \Test\TestCase {
public function testSetHeaders() {
- $expected = array(
+ $expected = [
'Last-Modified' => 1,
'ETag' => 3,
'Something-Else' => 'hi'
- );
+ ];
$this->childResponse->setHeaders($expected);
$headers = $this->childResponse->getHeaders();
@@ -105,31 +105,31 @@ class ResponseTest extends \Test\TestCase {
$this->childResponse->addCookie('foo', 'bar');
$this->childResponse->addCookie('bar', 'foo', new \DateTime('1970-01-01'));
- $expectedResponse = array(
- 'foo' => array(
+ $expectedResponse = [
+ 'foo' => [
'value' => 'bar',
'expireDate' => null,
- ),
- 'bar' => array(
+ ],
+ 'bar' => [
'value' => 'foo',
'expireDate' => new \DateTime('1970-01-01')
- )
- );
+ ]
+ ];
$this->assertEquals($expectedResponse, $this->childResponse->getCookies());
}
function testSetCookies() {
- $expected = array(
- 'foo' => array(
+ $expected = [
+ 'foo' => [
'value' => 'bar',
'expireDate' => null,
- ),
- 'bar' => array(
+ ],
+ 'bar' => [
'value' => 'foo',
'expireDate' => new \DateTime('1970-01-01')
- )
- );
+ ]
+ ];
$this->childResponse->setCookies($expected);
$cookies = $this->childResponse->getCookies();
@@ -141,12 +141,12 @@ class ResponseTest extends \Test\TestCase {
function testInvalidateCookie() {
$this->childResponse->addCookie('foo', 'bar');
$this->childResponse->invalidateCookie('foo');
- $expected = array(
- 'foo' => array(
+ $expected = [
+ 'foo' => [
'value' => 'expired',
'expireDate' => new \DateTime('1971-01-01')
- )
- );
+ ]
+ ];
$cookies = $this->childResponse->getCookies();
@@ -157,30 +157,30 @@ class ResponseTest extends \Test\TestCase {
function testInvalidateCookies() {
$this->childResponse->addCookie('foo', 'bar');
$this->childResponse->addCookie('bar', 'foo');
- $expected = array(
- 'foo' => array(
+ $expected = [
+ 'foo' => [
'value' => 'bar',
'expireDate' => null
- ),
- 'bar' => array(
+ ],
+ 'bar' => [
'value' => 'foo',
'expireDate' => null
- )
- );
+ ]
+ ];
$cookies = $this->childResponse->getCookies();
$this->assertEquals($expected, $cookies);
- $this->childResponse->invalidateCookies(array('foo', 'bar'));
- $expected = array(
- 'foo' => array(
+ $this->childResponse->invalidateCookies(['foo', 'bar']);
+ $expected = [
+ 'foo' => [
'value' => 'expired',
'expireDate' => new \DateTime('1971-01-01')
- ),
- 'bar' => array(
+ ],
+ 'bar' => [
'value' => 'expired',
'expireDate' => new \DateTime('1971-01-01')
- )
- );
+ ]
+ ];
$cookies = $this->childResponse->getCookies();
$this->assertEquals($expected, $cookies);
diff --git a/tests/lib/AppFramework/Http/TemplateResponseTest.php b/tests/lib/AppFramework/Http/TemplateResponseTest.php
index 6672b4d0c1e..af5b428cf86 100644
--- a/tests/lib/AppFramework/Http/TemplateResponseTest.php
+++ b/tests/lib/AppFramework/Http/TemplateResponseTest.php
@@ -41,26 +41,26 @@ class TemplateResponseTest extends \Test\TestCase {
public function testSetParamsConstructor(){
- $params = array('hi' => 'yo');
+ $params = ['hi' => 'yo'];
$this->tpl = new TemplateResponse('app', 'home', $params);
- $this->assertEquals(array('hi' => 'yo'), $this->tpl->getParams());
+ $this->assertEquals(['hi' => 'yo'], $this->tpl->getParams());
}
public function testSetRenderAsConstructor(){
$renderAs = 'myrender';
- $this->tpl = new TemplateResponse('app', 'home', array(), $renderAs);
+ $this->tpl = new TemplateResponse('app', 'home', [], $renderAs);
$this->assertEquals($renderAs, $this->tpl->getRenderAs());
}
public function testSetParams(){
- $params = array('hi' => 'yo');
+ $params = ['hi' => 'yo'];
$this->tpl->setParams($params);
- $this->assertEquals(array('hi' => 'yo'), $this->tpl->getParams());
+ $this->assertEquals(['hi' => 'yo'], $this->tpl->getParams());
}
@@ -75,12 +75,12 @@ class TemplateResponseTest extends \Test\TestCase {
}
public function testChainability() {
- $params = array('hi' => 'yo');
+ $params = ['hi' => 'yo'];
$this->tpl->setParams($params)
->setStatus(Http::STATUS_NOT_FOUND);
$this->assertEquals(Http::STATUS_NOT_FOUND, $this->tpl->getStatus());
- $this->assertEquals(array('hi' => 'yo'), $this->tpl->getParams());
+ $this->assertEquals(['hi' => 'yo'], $this->tpl->getParams());
}
}