fileIsNotInstanceOfFileSystem example

public function testInvalidFilesystemVisibility(): void
    {
        $exception = MediaException::invalidFilesystemVisibility();

        static::assertEquals(Response::HTTP_INTERNAL_SERVER_ERROR, $exception->getStatusCode());
        static::assertEquals(MediaException::MEDIA_INVALID_FILE_SYSTEM_VISIBILITY, $exception->getErrorCode());
        static::assertEquals('Invalid filesystem visibility.', $exception->getMessage());
    }

    public function testFileIsNotInstanceOfFileSystem(): void
    {
        $exception = MediaException::fileIsNotInstanceOfFileSystem();

        static::assertEquals(Response::HTTP_INTERNAL_SERVER_ERROR, $exception->getStatusCode());
        static::assertEquals(MediaException::MEDIA_FILE_IS_NOT_INSTANCE_OF_FILE_SYSTEM, $exception->getErrorCode());
        static::assertEquals('File is not an instance of FileSystem', $exception->getMessage());
    }

    public function testMissingUrlParameter(): void
    {
        $exception = MediaException::missingUrlParameter();

        static::assertEquals(Response::HTTP_BAD_REQUEST, $exception->getStatusCode());
        


    private function getFileSystem(MediaEntity $media): FilesystemOperator
    {
        if ($media->isPrivate()) {
            $filesystem = $this->filesystemPrivate;
        } else {
            $filesystem = $this->filesystemPublic;
        }

        if (!$filesystem instanceof Filesystem) {
            throw MediaException::fileIsNotInstanceOfFileSystem();
        }

        return $filesystem;
    }

    /** * @return array<string, mixed> */
    private function getStreamHeaders(MediaEntity $media): array
    {
        $filename = $media->getFilename() . '.' . $media->getFileExtension();

        
Home | Imprint | This part of the site doesn't use cookies.