fix assertEquals param order

This commit is contained in:
Milos Stojanovic
2021-02-02 16:16:33 +01:00
parent 44c215fa4a
commit 876c17eac5
2 changed files with 25 additions and 27 deletions

View File

@@ -163,37 +163,35 @@ class FilesTest extends TestCase
$path_encoded = base64_encode('john.txt'); $path_encoded = base64_encode('john.txt');
$this->sendRequest('GET', '/download&path='.$path_encoded); $this->sendRequest('GET', '/download&path='.$path_encoded);
$headers = $this->streamedResponse->headers; $headers = $this->streamedResponse->headers;
$this->assertEquals($headers->get('content-disposition'), "attachment; filename=file; filename*=utf-8''john.txt"); $this->assertEquals("attachment; filename=file; filename*=utf-8''john.txt", $headers->get('content-disposition'));
$this->assertEquals($headers->get('content-type'), 'text/plain'); $this->assertEquals('text/plain', $headers->get('content-type'));
$this->assertEquals($headers->get('content-transfer-encoding'), 'binary'); $this->assertEquals('binary', $headers->get('content-transfer-encoding'));
$this->assertEquals($headers->get('content-length'), 6); $this->assertEquals(6, $headers->get('content-length'));
$this->assertOk(); $this->assertOk();
$path_encoded = base64_encode('image.jpg'); $path_encoded = base64_encode('image.jpg');
$this->sendRequest('GET', '/download&path='.$path_encoded); $this->sendRequest('GET', '/download&path='.$path_encoded);
$headers = $this->streamedResponse->headers; $headers = $this->streamedResponse->headers;
$this->assertEquals($headers->get('content-disposition'), "attachment; filename=file; filename*=utf-8''image.jpg"); $this->assertEquals("attachment; filename=file; filename*=utf-8''image.jpg", $headers->get('content-disposition'));
$this->assertEquals($headers->get('content-type'), 'image/jpeg'); $this->assertEquals('image/jpeg', $headers->get('content-type'));
$this->assertEquals($headers->get('content-transfer-encoding'), 'binary'); $this->assertEquals('binary', $headers->get('content-transfer-encoding'));
$this->assertEquals($headers->get('content-length'), 0); $this->assertEquals(0, $headers->get('content-length'));
$this->assertOk(); $this->assertOk();
$path_encoded = base64_encode('vector.svg'); $path_encoded = base64_encode('vector.svg');
$this->sendRequest('GET', '/download&path='.$path_encoded); $this->sendRequest('GET', '/download&path='.$path_encoded);
$headers = $this->streamedResponse->headers; $headers = $this->streamedResponse->headers;
$this->assertEquals($headers->get('content-disposition'), "attachment; filename=file; filename*=utf-8''vector.svg"); $this->assertEquals("attachment; filename=file; filename*=utf-8''vector.svg", $headers->get('content-disposition'));
$this->assertEquals($headers->get('content-type'), 'image/svg+xml'); $this->assertEquals('image/svg+xml', $headers->get('content-type'));
$this->assertEquals($headers->get('content-transfer-encoding'), 'binary'); $this->assertEquals('binary', $headers->get('content-transfer-encoding'));
$this->assertEquals($headers->get('content-length'), 0);
$this->assertOk(); $this->assertOk();
$path_encoded = base64_encode('inlinedoc.pdf'); $path_encoded = base64_encode('inlinedoc.pdf');
$this->sendRequest('GET', '/download&path='.$path_encoded); $this->sendRequest('GET', '/download&path='.$path_encoded);
$headers = $this->streamedResponse->headers; $headers = $this->streamedResponse->headers;
$this->assertEquals($headers->get('content-disposition'), "inline; filename=file; filename*=utf-8''inlinedoc.pdf"); $this->assertEquals("inline; filename=file; filename*=utf-8''inlinedoc.pdf", $headers->get('content-disposition'));
$this->assertEquals($headers->get('content-type'), 'application/pdf'); $this->assertEquals('application/pdf', $headers->get('content-type'));
$this->assertEquals($headers->get('content-transfer-encoding'), 'binary'); $this->assertEquals('binary', $headers->get('content-transfer-encoding'));
$this->assertEquals($headers->get('content-length'), 0);
$this->assertOk(); $this->assertOk();
} }
@@ -209,10 +207,10 @@ class FilesTest extends TestCase
$this->sendRequest('GET', '/download&path='.$path_encoded); $this->sendRequest('GET', '/download&path='.$path_encoded);
$headers = $this->streamedResponse->headers; $headers = $this->streamedResponse->headers;
$this->assertEquals($headers->get('content-disposition'), "inline; filename=file; filename*=utf-8''john.pdf"); $this->assertEquals("inline; filename=file; filename*=utf-8''john.pdf", $headers->get('content-disposition'));
$this->assertEquals($headers->get('content-type'), 'application/pdf'); $this->assertEquals('application/pdf', $headers->get('content-type'));
$this->assertEquals($headers->get('content-transfer-encoding'), 'binary'); $this->assertEquals('binary', $headers->get('content-transfer-encoding'));
$this->assertEquals($headers->get('content-length'), 0); $this->assertEquals(0, $headers->get('content-length'));
$this->assertOk(); $this->assertOk();
} }
@@ -644,10 +642,10 @@ class FilesTest extends TestCase
// test headers // test headers
$this->response->getContent(); $this->response->getContent();
$headers = $this->streamedResponse->headers; $headers = $this->streamedResponse->headers;
$this->assertEquals($headers->get('content-type'), 'application/octet-stream'); $this->assertEquals('application/octet-stream', $headers->get('content-type'));
$this->assertEquals($headers->get('content-disposition'), 'attachment; filename=archive.zip'); $this->assertEquals('attachment; filename=archive.zip', $headers->get('content-disposition'));
$this->assertEquals($headers->get('content-transfer-encoding'), 'binary'); $this->assertEquals('binary', $headers->get('content-transfer-encoding'));
$this->assertEquals($headers->get('content-length'), 414); $this->assertEquals(414, $headers->get('content-length'));
} }
public function testUpdateFileContent() public function testUpdateFileContent()
@@ -667,7 +665,7 @@ class FilesTest extends TestCase
$updated = file_get_contents(TEST_REPOSITORY.'/john/john.txt'); $updated = file_get_contents(TEST_REPOSITORY.'/john/john.txt');
$this->assertEquals($updated, 'lorem ipsum new'); $this->assertEquals('lorem ipsum new', $updated);
} }
public function testUpdateFileContentInSubDir() public function testUpdateFileContentInSubDir()
@@ -692,6 +690,6 @@ class FilesTest extends TestCase
$updated = file_get_contents(TEST_REPOSITORY.'/john/sub/john.txt'); $updated = file_get_contents(TEST_REPOSITORY.'/john/sub/john.txt');
$this->assertEquals($updated, 'lorem ipsum new'); $this->assertEquals('lorem ipsum new', $updated);
} }
} }

View File

@@ -64,7 +64,7 @@ class TmpfsTest extends TestCase
$this->service->write('a.txt', 'lorem'); $this->service->write('a.txt', 'lorem');
$ret = $this->service->readStream('a.txt'); $ret = $this->service->readStream('a.txt');
$this->assertEquals($ret['filename'], 'a.txt'); $this->assertEquals('a.txt', $ret['filename']);
$contents = stream_get_contents($ret['stream']); $contents = stream_get_contents($ret['stream']);
$this->assertEquals('lorem', $contents); $this->assertEquals('lorem', $contents);