[TASK] Shorten the extend class in all unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Http / ServerRequestTest.php
index 7dcd663..9460e40 100644 (file)
@@ -14,162 +14,174 @@ namespace TYPO3\CMS\Core\Tests\Unit\Http;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Http\Uri;
 use TYPO3\CMS\Core\Http\ServerRequest;
 use TYPO3\CMS\Core\Http\UploadedFile;
+use TYPO3\CMS\Core\Http\Uri;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Testcase for \TYPO3\CMS\Core\Http\ServerRequest
  *
  * Adapted from https://github.com/phly/http/
  */
-class ServerRequestTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
-
-       /**
-        * @var ServerRequest
-        */
-       protected $request;
-
-       protected function setUp() {
-               $this->request = new ServerRequest();
-       }
-
-       /**
-        * @test
-        */
-       public function getServerParamsAreEmptyByDefault() {
-               $this->assertEmpty($this->request->getServerParams());
-       }
-
-       /**
-        * @test
-        */
-       public function getQueryParamsAreEmptyByDefault() {
-               $this->assertEmpty($this->request->getQueryParams());
-       }
-
-       /**
-        * @test
-        */
-       public function withQueryParamsMutatorReturnsCloneWithChanges() {
-               $value = ['foo' => 'bar'];
-               $request = $this->request->withQueryParams($value);
-               $this->assertNotSame($this->request, $request);
-               $this->assertEquals($value, $request->getQueryParams());
-       }
-
-       /**
-        * @test
-        */
-       public function getCookieParamsAreEmptyByDefault() {
-               $this->assertEmpty($this->request->getCookieParams());
-       }
-
-       /**
-        * @test
-        */
-       public function withCookieParamsMutatorReturnsCloneWithChanges() {
-               $value = ['foo' => 'bar'];
-               $request = $this->request->withCookieParams($value);
-               $this->assertNotSame($this->request, $request);
-               $this->assertEquals($value, $request->getCookieParams());
-       }
-
-       /**
-        * @test
-        */
-       public function getUploadedFilesAreEmptyByDefault() {
-               $this->assertEmpty($this->request->getUploadedFiles());
-       }
-
-       /**
-        * @test
-        */
-       public function getParsedBodyIsEmptyByDefault() {
-               $this->assertEmpty($this->request->getParsedBody());
-       }
-
-       /**
-        * @test
-        */
-       public function withParsedBodyMutatorReturnsCloneWithChanges() {
-               $value = ['foo' => 'bar'];
-               $request = $this->request->withParsedBody($value);
-               $this->assertNotSame($this->request, $request);
-               $this->assertEquals($value, $request->getParsedBody());
-       }
-
-       /**
-        * @test
-        */
-       public function getAttributesAreEmptyByDefault() {
-               $this->assertEmpty($this->request->getAttributes());
-       }
-
-       /**
-        * @depends testAttributesAreEmptyByDefault
-        * @test
-        */
-       public function withAttributeMutatorReturnsCloneWithChanges() {
-               $request = $this->request->withAttribute('foo', 'bar');
-               $this->assertNotSame($this->request, $request);
-               $this->assertEquals('bar', $request->getAttribute('foo'));
-
-               return $request;
-       }
-
-       /**
-        * @depends testAttributeMutatorReturnsCloneWithChanges
-        * @test
-        */
-       public function withoutAttributeReturnsCloneWithoutAttribute($request) {
-               $new = $request->withoutAttribute('foo');
-               $this->assertNotSame($request, $new);
-               $this->assertNull($new->getAttribute('foo', NULL));
-       }
-
-       /**
-        * @test
-        */
-       public function constructorUsesProvidedArguments() {
-               $server = [
-                       'foo' => 'bar',
-                       'baz' => 'bat',
-               ];
-
-               $server['server'] = TRUE;
-
-               $files = [
-                       'files' => new UploadedFile('php://temp', 0, 0),
-               ];
-
-               $uri = new Uri('http://example.com');
-               $method = 'POST';
-               $headers = [
-                       'host' => ['example.com'],
-               ];
-
-               $request = new ServerRequest(
-                       $uri,
-                       $method,
-                       'php://memory',
-                       $headers,
-                       $server,
-                       $files
-               );
-
-               $this->assertEquals($server, $request->getServerParams());
-               $this->assertEquals($files, $request->getUploadedFiles());
-
-               $this->assertSame($uri, $request->getUri());
-               $this->assertEquals($method, $request->getMethod());
-               $this->assertEquals($headers, $request->getHeaders());
-
-               $body = $request->getBody();
-               $r = new \ReflectionProperty($body, 'stream');
-               $r->setAccessible(TRUE);
-               $stream = $r->getValue($body);
-               $this->assertEquals('php://memory', $stream);
-       }
-
+class ServerRequestTest extends UnitTestCase
+{
+    /**
+     * @var ServerRequest
+     */
+    protected $request;
+
+    protected function setUp()
+    {
+        $this->request = new ServerRequest();
+    }
+
+    /**
+     * @test
+     */
+    public function getServerParamsAreEmptyByDefault()
+    {
+        $this->assertEmpty($this->request->getServerParams());
+    }
+
+    /**
+     * @test
+     */
+    public function getQueryParamsAreEmptyByDefault()
+    {
+        $this->assertEmpty($this->request->getQueryParams());
+    }
+
+    /**
+     * @test
+     */
+    public function withQueryParamsMutatorReturnsCloneWithChanges()
+    {
+        $value = ['foo' => 'bar'];
+        $request = $this->request->withQueryParams($value);
+        $this->assertNotSame($this->request, $request);
+        $this->assertEquals($value, $request->getQueryParams());
+    }
+
+    /**
+     * @test
+     */
+    public function getCookieParamsAreEmptyByDefault()
+    {
+        $this->assertEmpty($this->request->getCookieParams());
+    }
+
+    /**
+     * @test
+     */
+    public function withCookieParamsMutatorReturnsCloneWithChanges()
+    {
+        $value = ['foo' => 'bar'];
+        $request = $this->request->withCookieParams($value);
+        $this->assertNotSame($this->request, $request);
+        $this->assertEquals($value, $request->getCookieParams());
+    }
+
+    /**
+     * @test
+     */
+    public function getUploadedFilesAreEmptyByDefault()
+    {
+        $this->assertEmpty($this->request->getUploadedFiles());
+    }
+
+    /**
+     * @test
+     */
+    public function getParsedBodyIsEmptyByDefault()
+    {
+        $this->assertEmpty($this->request->getParsedBody());
+    }
+
+    /**
+     * @test
+     */
+    public function withParsedBodyMutatorReturnsCloneWithChanges()
+    {
+        $value = ['foo' => 'bar'];
+        $request = $this->request->withParsedBody($value);
+        $this->assertNotSame($this->request, $request);
+        $this->assertEquals($value, $request->getParsedBody());
+    }
+
+    /**
+     * @test
+     */
+    public function getAttributesAreEmptyByDefault()
+    {
+        $this->assertEmpty($this->request->getAttributes());
+    }
+
+    /**
+     * @test
+     */
+    public function withAttributeMutatorReturnsCloneWithChanges()
+    {
+        $request = $this->request->withAttribute('foo', 'bar');
+        $this->assertNotSame($this->request, $request);
+        $this->assertEquals('bar', $request->getAttribute('foo'));
+
+        return $request;
+    }
+
+    /**
+     * @test
+     */
+    public function withoutAttributeReturnsCloneWithoutAttribute()
+    {
+        $request = $this->request;
+        $new = $request->withoutAttribute('foo');
+        $this->assertNotSame($request, $new);
+        $this->assertNull($new->getAttribute('foo', null));
+    }
+
+    /**
+     * @test
+     */
+    public function constructorUsesProvidedArguments()
+    {
+        $server = [
+            'foo' => 'bar',
+            'baz' => 'bat',
+        ];
+
+        $server['server'] = true;
+
+        $files = [
+            'files' => new UploadedFile('php://temp', 0, 0),
+        ];
+
+        $uri = new Uri('http://example.com');
+        $method = 'POST';
+        $headers = [
+            'host' => ['example.com'],
+        ];
+
+        $request = new ServerRequest(
+            $uri,
+            $method,
+            'php://memory',
+            $headers,
+            $server,
+            $files
+        );
+
+        $this->assertEquals($server, $request->getServerParams());
+        $this->assertEquals($files, $request->getUploadedFiles());
+
+        $this->assertSame($uri, $request->getUri());
+        $this->assertEquals($method, $request->getMethod());
+        $this->assertEquals($headers, $request->getHeaders());
+
+        $body = $request->getBody();
+        $r = new \ReflectionProperty($body, 'stream');
+        $r->setAccessible(true);
+        $stream = $r->getValue($body);
+        $this->assertEquals('php://memory', $stream);
+    }
 }