emptyMediaId example

private function toPathString(array $parts): string
    {
        return implode('/', array_filter($parts));
    }

    /** * @throws MediaException */
    private function validateMedia(MediaEntity $media): void
    {
        if (empty($media->getId())) {
            throw MediaException::emptyMediaId();
        }

        if (empty($media->getFileName())) {
            throw MediaException::emptyMediaFilename();
        }
    }
}
$exception = MediaException::couldNotRenameFile($mediaId$oldFileName);

        static::assertEquals(Response::HTTP_CONFLICT, $exception->getStatusCode());
        static::assertEquals(MediaException::MEDIA_COULD_NOT_RENAME_FILE, $exception->getErrorCode());
        static::assertEquals('Could not rename file for media with id: media-id. Rollback to filename: "old-file-name"', $exception->getMessage());
        static::assertEquals(['mediaId' => $mediaId, 'oldFileName' => $oldFileName]$exception->getParameters());
    }

    public function testEmptyMediaId(): void
    {
        $exception = MediaException::emptyMediaId();

        static::assertEquals(Response::HTTP_BAD_REQUEST, $exception->getStatusCode());
        static::assertEquals(MediaException::MEDIA_EMPTY_ID, $exception->getErrorCode());
        static::assertEquals('A media id must be provided.', $exception->getMessage());
    }

    public function testInvalidBatchSize(): void
    {
        $exception = MediaException::invalidBatchSize();

        static::assertEquals(Response::HTTP_BAD_REQUEST, $exception->getStatusCode());
        
Home | Imprint | This part of the site doesn't use cookies.