Skip to content

Commit

Permalink
tests for pixel format support, see #1302
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Dec 10, 2024
1 parent 7854599 commit e84df53
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ FROM unit:php8.3 AS base
RUN apt update && \
apt upgrade -y && \
apt install -y --no-install-recommends \
curl rsync imagemagick zip unzip libpq-dev libpng-dev libzip-dev && \
curl rsync imagemagick zip unzip libpq-dev libpng-dev libjpeg-dev libzip-dev libwebp-dev && \
rm -rf /var/lib/apt/lists/*
RUN pecl install redis-6.1.0 && docker-php-ext-enable redis
RUN pecl install apcu-5.1.24 && docker-php-ext-enable apcu
RUN apt-get update && apt-get install -y libmemcached-dev libssl-dev zlib1g-dev && \
pecl install memcached-3.3.0 && docker-php-ext-enable memcached
RUN docker-php-ext-install mysqli pgsql pdo pdo_mysql pdo_pgsql gd zip pcntl
RUN docker-php-ext-configure gd --with-jpeg --with-webp && \
docker-php-ext-install gd
RUN docker-php-ext-install mysqli pgsql pdo pdo_mysql pdo_pgsql zip pcntl

# Install dev packages
# Things which are only needed during development - Composer has 100MB of
Expand Down
35 changes: 35 additions & 0 deletions ext/handle_pixel/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Shimmie2;

use PHPUnit\Framework\Attributes\DataProvider;

class PixelFileHandlerTest extends ShimmiePHPUnitTestCase
{
public function testPixelHander(): void
Expand All @@ -17,4 +19,37 @@ public function testPixelHander(): void
# FIXME: test that the thumb works
# FIXME: test that it gets displayed properly
}

/**
* @return array<array<string>>
*/
public static function formatList(): array
{
return [
["jpeg"],
["png"],
["gif"],
];
}

#[DataProvider('formatList')]
public function testFormats(string $format): void
{
$tmp = shm_tempnam("test-format");
unlink($tmp);
$img = \Safe\imagecreatefromstring(\Safe\file_get_contents("tests/pbx_screenshot.jpg"));
("image$format")($img, "$tmp.$format");

Check failure on line 41 in ext/handle_pixel/test.php

View workflow job for this annotation

GitHub Actions / Static Analysis

Trying to invoke non-falsy-string but it might not be a callable.

$image_id = $this->post_image("$tmp.$format", "pbx computer screenshot $format");
$page = $this->get_page("post/view/$image_id");
$this->assertEquals(200, $page->code);
}

public function tearDown(): void
{
parent::tearDown();
foreach (\Safe\glob("data/temp/test-format*") as $file) {
unlink($file);
}
}
}

0 comments on commit e84df53

Please sign in to comment.