404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.191.132.7: ~ $
<?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\Mime\Tests;

use Symfony\Component\Mime\Exception\RuntimeException;
use Symfony\Component\Mime\MimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypes;

/**
 * @requires extension fileinfo
 */
class MimeTypesTest extends AbstractMimeTypeGuesserTestCase
{
    protected function getGuesser(): MimeTypeGuesserInterface
    {
        return new MimeTypes();
    }

    public function testUnsupportedGuesser()
    {
        $guesser = $this->getGuesser();
        $guesser->registerGuesser(new class() implements MimeTypeGuesserInterface {
            public function isGuesserSupported(): bool
            {
                return false;
            }

            public function guessMimeType(string $mimeType): ?string
            {
                throw new RuntimeException('Should never be called.');
            }
        });
        $this->assertEquals('image/gif', $guesser->guessMimeType(__DIR__.'/Fixtures/mimetypes/test'));
    }

    public function testGetExtensions()
    {
        $mt = new MimeTypes();
        $this->assertSame(['mbox'], $mt->getExtensions('application/mbox'));
        $this->assertSame(['ai', 'eps', 'ps'], $mt->getExtensions('application/postscript'));
        $this->assertContains('svg', $mt->getExtensions('image/svg+xml'));
        $this->assertContains('svg', $mt->getExtensions('image/svg'));
        $this->assertSame([], $mt->getExtensions('application/whatever-symfony'));
    }

    public function testGetMimeTypes()
    {
        $mt = new MimeTypes();
        $this->assertSame(['application/mbox'], $mt->getMimeTypes('mbox'));
        $this->assertContains('application/postscript', $mt->getMimeTypes('ai'));
        $this->assertContains('application/postscript', $mt->getMimeTypes('ps'));
        $this->assertContains('image/svg+xml', $mt->getMimeTypes('svg'));
        $this->assertContains('image/svg', $mt->getMimeTypes('svg'));
        $this->assertSame([], $mt->getMimeTypes('symfony'));
    }

    public function testCustomMimeTypes()
    {
        $mt = new MimeTypes([
            'text/bar' => ['foo'],
            'text/baz' => ['foo', 'moof'],
        ]);
        $this->assertContains('text/bar', $mt->getMimeTypes('foo'));
        $this->assertContains('text/baz', $mt->getMimeTypes('foo'));
        $this->assertSame(['foo', 'moof'], $mt->getExtensions('text/baz'));
    }

    public function testCsvExtension()
    {
        $mt = new MimeTypes();

        $mime = $mt->guessMimeType(__DIR__.'/Fixtures/mimetypes/abc.csv');
        $this->assertContains($mime, ['application/csv', 'text/csv']);
        $this->assertSame(['csv'], $mt->getExtensions($mime));
    }
}

Filemanager

Name Type Size Permission Actions
Crypto Folder 0755
DependencyInjection Folder 0755
Encoder Folder 0755
Fixtures Folder 0755
Header Folder 0755
HtmlToTextConverter Folder 0755
Part Folder 0755
_data Folder 0755
AbstractMimeTypeGuesserTestCase.php File 4.15 KB 0644
AddressTest.php File 4.92 KB 0644
CharacterStreamTest.php File 3.33 KB 0644
DraftEmailTest.php File 1.53 KB 0644
EmailTest.php File 25.54 KB 0644
FileBinaryMimeTypeGuesserTest.php File 753 B 0644
FileinfoMimeTypeGuesserTest.php File 649 B 0644
MessageConverterTest.php File 3.43 KB 0644
MessageTest.php File 10.24 KB 0644
MimeTypesTest.php File 2.92 KB 0644
RawMessageTest.php File 1.89 KB 0644