missingUrlParameter example

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());
        static::assertEquals(MediaException::MEDIA_MISSING_URL_PARAMETER, $exception->getErrorCode());
        static::assertEquals('Parameter url is missing.', $exception->getMessage());
    }

    public function testCannotCreateTempFile(): void
    {
        $exception = MediaException::cannotCreateTempFile();

        static::assertEquals(Response::HTTP_INTERNAL_SERVER_ERROR, $exception->getStatusCode());
        
return $extension;
    }

    /** * @throws MediaException */
    private function getUrlFromRequest(Request $request): string
    {
        $url = (string) $request->request->get('url');

        if ($url === '') {
            throw MediaException::missingUrlParameter();
        }

        if (!$this->isUrlValid($url)) {
            throw MediaException::invalidUrl($url);
        }

        return $url;
    }

    /** * @throws MediaException * * @return resource */
Home | Imprint | This part of the site doesn't use cookies.