aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/php/vendor/symfony/http-foundation/Tests/File
diff options
context:
space:
mode:
authormarvin-borner@live.com2018-04-16 21:09:05 +0200
committermarvin-borner@live.com2018-04-16 21:09:05 +0200
commitcf14306c2b3f82a81f8d56669a71633b4d4b5fce (patch)
tree86700651aa180026e89a66064b0364b1e4346f3f /assets/php/vendor/symfony/http-foundation/Tests/File
parent619b01b3615458c4ed78bfaeabb6b1a47cc8ad8b (diff)
Main merge to user management system - files are now at /main/public/
Diffstat (limited to 'assets/php/vendor/symfony/http-foundation/Tests/File')
-rwxr-xr-xassets/php/vendor/symfony/http-foundation/Tests/File/FakeFile.php45
-rwxr-xr-xassets/php/vendor/symfony/http-foundation/Tests/File/FileTest.php180
-rwxr-xr-xassets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/.unknownextension1
-rwxr-xr-xassets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/directory/.empty0
-rwxr-xr-xassets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/other-file.example0
-rwxr-xr-xassets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/testbin35 -> 0 bytes
-rwxr-xr-xassets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/test.gifbin35 -> 0 bytes
-rwxr-xr-xassets/php/vendor/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php90
-rwxr-xr-xassets/php/vendor/symfony/http-foundation/Tests/File/UploadedFileTest.php273
9 files changed, 0 insertions, 589 deletions
diff --git a/assets/php/vendor/symfony/http-foundation/Tests/File/FakeFile.php b/assets/php/vendor/symfony/http-foundation/Tests/File/FakeFile.php
deleted file mode 100755
index c415989..0000000
--- a/assets/php/vendor/symfony/http-foundation/Tests/File/FakeFile.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\HttpFoundation\Tests\File;
-
-use Symfony\Component\HttpFoundation\File\File as OrigFile;
-
-class FakeFile extends OrigFile
-{
- private $realpath;
-
- public function __construct($realpath, $path)
- {
- $this->realpath = $realpath;
- parent::__construct($path, false);
- }
-
- public function isReadable()
- {
- return true;
- }
-
- public function getRealpath()
- {
- return $this->realpath;
- }
-
- public function getSize()
- {
- return 42;
- }
-
- public function getMTime()
- {
- return time();
- }
-}
diff --git a/assets/php/vendor/symfony/http-foundation/Tests/File/FileTest.php b/assets/php/vendor/symfony/http-foundation/Tests/File/FileTest.php
deleted file mode 100755
index dbd9c44..0000000
--- a/assets/php/vendor/symfony/http-foundation/Tests/File/FileTest.php
+++ /dev/null
@@ -1,180 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\HttpFoundation\Tests\File;
-
-use PHPUnit\Framework\TestCase;
-use Symfony\Component\HttpFoundation\File\File;
-use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
-
-class FileTest extends TestCase
-{
- protected $file;
-
- public function testGetMimeTypeUsesMimeTypeGuessers()
- {
- $file = new File(__DIR__.'/Fixtures/test.gif');
- $guesser = $this->createMockGuesser($file->getPathname(), 'image/gif');
-
- MimeTypeGuesser::getInstance()->register($guesser);
-
- $this->assertEquals('image/gif', $file->getMimeType());
- }
-
- public function testGuessExtensionWithoutGuesser()
- {
- $file = new File(__DIR__.'/Fixtures/directory/.empty');
-
- $this->assertNull($file->guessExtension());
- }
-
- public function testGuessExtensionIsBasedOnMimeType()
- {
- $file = new File(__DIR__.'/Fixtures/test');
- $guesser = $this->createMockGuesser($file->getPathname(), 'image/gif');
-
- MimeTypeGuesser::getInstance()->register($guesser);
-
- $this->assertEquals('gif', $file->guessExtension());
- }
-
- /**
- * @requires extension fileinfo
- */
- public function testGuessExtensionWithReset()
- {
- $file = new File(__DIR__.'/Fixtures/other-file.example');
- $guesser = $this->createMockGuesser($file->getPathname(), 'image/gif');
- MimeTypeGuesser::getInstance()->register($guesser);
-
- $this->assertEquals('gif', $file->guessExtension());
-
- MimeTypeGuesser::reset();
-
- $this->assertNull($file->guessExtension());
- }
-
- public function testConstructWhenFileNotExists()
- {
- $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
-
- new File(__DIR__.'/Fixtures/not_here');
- }
-
- public function testMove()
- {
- $path = __DIR__.'/Fixtures/test.copy.gif';
- $targetDir = __DIR__.'/Fixtures/directory';
- $targetPath = $targetDir.'/test.copy.gif';
- @unlink($path);
- @unlink($targetPath);
- copy(__DIR__.'/Fixtures/test.gif', $path);
-
- $file = new File($path);
- $movedFile = $file->move($targetDir);
- $this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $movedFile);
-
- $this->assertFileExists($targetPath);
- $this->assertFileNotExists($path);
- $this->assertEquals(realpath($targetPath), $movedFile->getRealPath());
-
- @unlink($targetPath);
- }
-
- public function testMoveWithNewName()
- {
- $path = __DIR__.'/Fixtures/test.copy.gif';
- $targetDir = __DIR__.'/Fixtures/directory';
- $targetPath = $targetDir.'/test.newname.gif';
- @unlink($path);
- @unlink($targetPath);
- copy(__DIR__.'/Fixtures/test.gif', $path);
-
- $file = new File($path);
- $movedFile = $file->move($targetDir, 'test.newname.gif');
-
- $this->assertFileExists($targetPath);
- $this->assertFileNotExists($path);
- $this->assertEquals(realpath($targetPath), $movedFile->getRealPath());
-
- @unlink($targetPath);
- }
-
- public function getFilenameFixtures()
- {
- return array(
- array('original.gif', 'original.gif'),
- array('..\\..\\original.gif', 'original.gif'),
- array('../../original.gif', 'original.gif'),
- array('файлfile.gif', 'файлfile.gif'),
- array('..\\..\\файлfile.gif', 'файлfile.gif'),
- array('../../файлfile.gif', 'файлfile.gif'),
- );
- }
-
- /**
- * @dataProvider getFilenameFixtures
- */
- public function testMoveWithNonLatinName($filename, $sanitizedFilename)
- {
- $path = __DIR__.'/Fixtures/'.$sanitizedFilename;
- $targetDir = __DIR__.'/Fixtures/directory/';
- $targetPath = $targetDir.$sanitizedFilename;
- @unlink($path);
- @unlink($targetPath);
- copy(__DIR__.'/Fixtures/test.gif', $path);
-
- $file = new File($path);
- $movedFile = $file->move($targetDir, $filename);
- $this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $movedFile);
-
- $this->assertFileExists($targetPath);
- $this->assertFileNotExists($path);
- $this->assertEquals(realpath($targetPath), $movedFile->getRealPath());
-
- @unlink($targetPath);
- }
-
- public function testMoveToAnUnexistentDirectory()
- {
- $sourcePath = __DIR__.'/Fixtures/test.copy.gif';
- $targetDir = __DIR__.'/Fixtures/directory/sub';
- $targetPath = $targetDir.'/test.copy.gif';
- @unlink($sourcePath);
- @unlink($targetPath);
- @rmdir($targetDir);
- copy(__DIR__.'/Fixtures/test.gif', $sourcePath);
-
- $file = new File($sourcePath);
- $movedFile = $file->move($targetDir);
-
- $this->assertFileExists($targetPath);
- $this->assertFileNotExists($sourcePath);
- $this->assertEquals(realpath($targetPath), $movedFile->getRealPath());
-
- @unlink($sourcePath);
- @unlink($targetPath);
- @rmdir($targetDir);
- }
-
- protected function createMockGuesser($path, $mimeType)
- {
- $guesser = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface')->getMock();
- $guesser
- ->expects($this->once())
- ->method('guess')
- ->with($this->equalTo($path))
- ->will($this->returnValue($mimeType))
- ;
-
- return $guesser;
- }
-}
diff --git a/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/.unknownextension b/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/.unknownextension
deleted file mode 100755
index 4d1ae35..0000000
--- a/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/.unknownextension
+++ /dev/null
@@ -1 +0,0 @@
-f \ No newline at end of file
diff --git a/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/directory/.empty b/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/directory/.empty
deleted file mode 100755
index e69de29..0000000
--- a/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/directory/.empty
+++ /dev/null
diff --git a/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/other-file.example b/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/other-file.example
deleted file mode 100755
index e69de29..0000000
--- a/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/other-file.example
+++ /dev/null
diff --git a/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/test b/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/test
deleted file mode 100755
index b636f4b..0000000
--- a/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/test
+++ /dev/null
Binary files differ
diff --git a/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/test.gif b/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/test.gif
deleted file mode 100755
index b636f4b..0000000
--- a/assets/php/vendor/symfony/http-foundation/Tests/File/Fixtures/test.gif
+++ /dev/null
Binary files differ
diff --git a/assets/php/vendor/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php b/assets/php/vendor/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php
deleted file mode 100755
index b3f1f02..0000000
--- a/assets/php/vendor/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\HttpFoundation\Tests\File\MimeType;
-
-use PHPUnit\Framework\TestCase;
-use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
-use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser;
-
-/**
- * @requires extension fileinfo
- */
-class MimeTypeTest extends TestCase
-{
- protected $path;
-
- public function testGuessImageWithoutExtension()
- {
- $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
- }
-
- public function testGuessImageWithDirectory()
- {
- $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
-
- MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/directory');
- }
-
- public function testGuessImageWithFileBinaryMimeTypeGuesser()
- {
- $guesser = MimeTypeGuesser::getInstance();
- $guesser->register(new FileBinaryMimeTypeGuesser());
- $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
- }
-
- public function testGuessImageWithKnownExtension()
- {
- $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.gif'));
- }
-
- public function testGuessFileWithUnknownExtension()
- {
- $this->assertEquals('application/octet-stream', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/.unknownextension'));
- }
-
- public function testGuessWithIncorrectPath()
- {
- $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
- MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/not_here');
- }
-
- public function testGuessWithNonReadablePath()
- {
- if ('\\' === DIRECTORY_SEPARATOR) {
- $this->markTestSkipped('Can not verify chmod operations on Windows');
- }
-
- if (!getenv('USER') || 'root' === getenv('USER')) {
- $this->markTestSkipped('This test will fail if run under superuser');
- }
-
- $path = __DIR__.'/../Fixtures/to_delete';
- touch($path);
- @chmod($path, 0333);
-
- if ('0333' == substr(sprintf('%o', fileperms($path)), -4)) {
- $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException');
- MimeTypeGuesser::getInstance()->guess($path);
- } else {
- $this->markTestSkipped('Can not verify chmod operations, change of file permissions failed');
- }
- }
-
- public static function tearDownAfterClass()
- {
- $path = __DIR__.'/../Fixtures/to_delete';
- if (file_exists($path)) {
- @chmod($path, 0666);
- @unlink($path);
- }
- }
-}
diff --git a/assets/php/vendor/symfony/http-foundation/Tests/File/UploadedFileTest.php b/assets/php/vendor/symfony/http-foundation/Tests/File/UploadedFileTest.php
deleted file mode 100755
index 36f122f..0000000
--- a/assets/php/vendor/symfony/http-foundation/Tests/File/UploadedFileTest.php
+++ /dev/null
@@ -1,273 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\HttpFoundation\Tests\File;
-
-use PHPUnit\Framework\TestCase;
-use Symfony\Component\HttpFoundation\File\UploadedFile;
-
-class UploadedFileTest extends TestCase
-{
- protected function setUp()
- {
- if (!ini_get('file_uploads')) {
- $this->markTestSkipped('file_uploads is disabled in php.ini');
- }
- }
-
- public function testConstructWhenFileNotExists()
- {
- $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
-
- new UploadedFile(
- __DIR__.'/Fixtures/not_here',
- 'original.gif',
- null
- );
- }
-
- public function testFileUploadsWithNoMimeType()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- 'original.gif',
- null,
- filesize(__DIR__.'/Fixtures/test.gif'),
- UPLOAD_ERR_OK
- );
-
- $this->assertEquals('application/octet-stream', $file->getClientMimeType());
-
- if (extension_loaded('fileinfo')) {
- $this->assertEquals('image/gif', $file->getMimeType());
- }
- }
-
- public function testFileUploadsWithUnknownMimeType()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/.unknownextension',
- 'original.gif',
- null,
- filesize(__DIR__.'/Fixtures/.unknownextension'),
- UPLOAD_ERR_OK
- );
-
- $this->assertEquals('application/octet-stream', $file->getClientMimeType());
- }
-
- public function testGuessClientExtension()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- 'original.gif',
- 'image/gif',
- filesize(__DIR__.'/Fixtures/test.gif'),
- null
- );
-
- $this->assertEquals('gif', $file->guessClientExtension());
- }
-
- public function testGuessClientExtensionWithIncorrectMimeType()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- 'original.gif',
- 'image/jpeg',
- filesize(__DIR__.'/Fixtures/test.gif'),
- null
- );
-
- $this->assertEquals('jpeg', $file->guessClientExtension());
- }
-
- public function testErrorIsOkByDefault()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- 'original.gif',
- 'image/gif',
- filesize(__DIR__.'/Fixtures/test.gif'),
- null
- );
-
- $this->assertEquals(UPLOAD_ERR_OK, $file->getError());
- }
-
- public function testGetClientOriginalName()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- 'original.gif',
- 'image/gif',
- filesize(__DIR__.'/Fixtures/test.gif'),
- null
- );
-
- $this->assertEquals('original.gif', $file->getClientOriginalName());
- }
-
- public function testGetClientOriginalExtension()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- 'original.gif',
- 'image/gif',
- filesize(__DIR__.'/Fixtures/test.gif'),
- null
- );
-
- $this->assertEquals('gif', $file->getClientOriginalExtension());
- }
-
- /**
- * @expectedException \Symfony\Component\HttpFoundation\File\Exception\FileException
- */
- public function testMoveLocalFileIsNotAllowed()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- 'original.gif',
- 'image/gif',
- filesize(__DIR__.'/Fixtures/test.gif'),
- UPLOAD_ERR_OK
- );
-
- $movedFile = $file->move(__DIR__.'/Fixtures/directory');
- }
-
- public function testMoveLocalFileIsAllowedInTestMode()
- {
- $path = __DIR__.'/Fixtures/test.copy.gif';
- $targetDir = __DIR__.'/Fixtures/directory';
- $targetPath = $targetDir.'/test.copy.gif';
- @unlink($path);
- @unlink($targetPath);
- copy(__DIR__.'/Fixtures/test.gif', $path);
-
- $file = new UploadedFile(
- $path,
- 'original.gif',
- 'image/gif',
- filesize($path),
- UPLOAD_ERR_OK,
- true
- );
-
- $movedFile = $file->move(__DIR__.'/Fixtures/directory');
-
- $this->assertFileExists($targetPath);
- $this->assertFileNotExists($path);
- $this->assertEquals(realpath($targetPath), $movedFile->getRealPath());
-
- @unlink($targetPath);
- }
-
- public function testGetClientOriginalNameSanitizeFilename()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- '../../original.gif',
- 'image/gif',
- filesize(__DIR__.'/Fixtures/test.gif'),
- null
- );
-
- $this->assertEquals('original.gif', $file->getClientOriginalName());
- }
-
- public function testGetSize()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- 'original.gif',
- 'image/gif',
- filesize(__DIR__.'/Fixtures/test.gif'),
- null
- );
-
- $this->assertEquals(filesize(__DIR__.'/Fixtures/test.gif'), $file->getSize());
-
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test',
- 'original.gif',
- 'image/gif'
- );
-
- $this->assertEquals(filesize(__DIR__.'/Fixtures/test'), $file->getSize());
- }
-
- public function testGetExtension()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- 'original.gif',
- null
- );
-
- $this->assertEquals('gif', $file->getExtension());
- }
-
- public function testIsValid()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- 'original.gif',
- null,
- filesize(__DIR__.'/Fixtures/test.gif'),
- UPLOAD_ERR_OK,
- true
- );
-
- $this->assertTrue($file->isValid());
- }
-
- /**
- * @dataProvider uploadedFileErrorProvider
- */
- public function testIsInvalidOnUploadError($error)
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- 'original.gif',
- null,
- filesize(__DIR__.'/Fixtures/test.gif'),
- $error
- );
-
- $this->assertFalse($file->isValid());
- }
-
- public function uploadedFileErrorProvider()
- {
- return array(
- array(UPLOAD_ERR_INI_SIZE),
- array(UPLOAD_ERR_FORM_SIZE),
- array(UPLOAD_ERR_PARTIAL),
- array(UPLOAD_ERR_NO_TMP_DIR),
- array(UPLOAD_ERR_EXTENSION),
- );
- }
-
- public function testIsInvalidIfNotHttpUpload()
- {
- $file = new UploadedFile(
- __DIR__.'/Fixtures/test.gif',
- 'original.gif',
- null,
- filesize(__DIR__.'/Fixtures/test.gif'),
- UPLOAD_ERR_OK
- );
-
- $this->assertFalse($file->isValid());
- }
-}