/** * @test */ public function toStringSerializationReturnsEmptyStringWhenStreamIsNotReadable() { $fileName = PATH_site . 'typo3temp/' . $this->getUniqueId('test_'); touch($fileName); $this->testFilesToDelete[] = $fileName; file_put_contents($fileName, 'FOO BAR'); $stream = new Stream($fileName, 'w'); $this->assertEquals('', $stream->__toString()); }
/** * @test */ public function moveToMovesFileToDesignatedPath() { $stream = new Stream('php://temp', 'wb+'); $stream->write('Foo bar!'); $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK); $this->tmpFile = $to = GeneralUtility::tempnam('psr7'); $upload->moveTo($to); $this->assertTrue(file_exists($to)); $contents = file_get_contents($to); $this->assertEquals($stream->__toString(), $contents); }