Skip to content

Commit

Permalink
Add test for IiifUrlReader
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-stoehr committed Feb 8, 2023
1 parent 090b249 commit e19eb0f
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Build/Test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ services:
"
unit:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
build: unit-${DOCKER_PHP_IMAGE}
user: "${HOST_UID}:${HOST_GID}"
volumes:
- ${DLF_ROOT}:${DLF_ROOT}
Expand Down
49 changes: 49 additions & 0 deletions Build/Test/unit-php74/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM php:7.4-alpine
MAINTAINER Christian Kuhn <[email protected]>

# We use convenient install-php-extensions script to manage additional php extensions
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN apk add --no-cache \
bash \
file \
git \
graphicsmagick \
grep \
patch \
&& chmod +x /usr/local/bin/install-php-extensions \
&& sync \
&& install-php-extensions \
apcu \
bcmath \
bz2 \
@composer-2 \
gd \
gettext \
gmp \
intl \
memcached \
mysqli \
opcache \
pdo_mysql \
pdo_pgsql \
pdo_sqlsrv \
pgsql \
pspell \
redis \
soap \
sockets \
sqlsrv \
sysvsem \
# we need to pin xdebug to a specific version now, as 3.2+ is not compatible with image php version
xdebug-3.1.5 \
zip \
&& mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
&& sed -i s/';phar.readonly = On'/'phar.readonly = Off'/ $PHP_INI_DIR/php.ini \
&& sed -i s/'memory_limit = 128M'/'memory_limit = 2G'/ $PHP_INI_DIR/php.ini \
&& sed -i s/'max_execution_time = 30'/'max_execution_time = 240'/ $PHP_INI_DIR/php.ini \
&& sed -i s/';max_input_vars = 1000'/'max_input_vars = 1500'/ $PHP_INI_DIR/php.ini \
&& echo "xdebug.max_nesting_level = 400" >> $PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini \
&& echo "apc.enable_cli=1" >> $PHP_INI_DIR/conf.d/docker-php-ext-apcu.ini \
&& echo "apc.slam_defense=0" >> $PHP_INI_DIR/conf.d/docker-php-ext-apcu.ini \
&& rm -rf /var/cache/apk/*
40 changes: 40 additions & 0 deletions Tests/Unit/Common/IiifUrlReaderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Kitodo\Dlf\Tests\Unit\Common;

use Kitodo\Dlf\Common\IiifUrlReader;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
use donatj\MockWebServer\MockWebServer;
use donatj\MockWebServer\Response;

class IiifUrlReaderTest extends UnitTestCase
{

/** @var MockWebServer */
protected static $mockServer;

public static function setUpBeforeClass() : void {
self::$mockServer = new MockWebServer;
self::$mockServer->start();
}

public static function tearDownAfterClass() : void {
// stopping the web server during tear down allows us to reuse the port for later tests
self::$mockServer->stop();
}

/**
* @test
* @group getContent
*/
public function getContentCheck() {
$iiifUrlReader = new IiifUrlReader();

$correctUrl = self::$mockServer->setResponseOfPath('/correctPath', new Response('Correct result'));
$this->assertSame('Correct result', $iiifUrlReader->getContent($correctUrl));

$incorrectUrl = self::$mockServer->setResponseOfPath('/incorrectPath',
new Response('', [], 500));
$this->assertSame('', $iiifUrlReader->getContent($incorrectUrl));
}
}
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@
"solarium/solarium": "^5.2"
},
"require-dev": {
"ext-sockets": "*",
"spatie/phpunit-watcher": "^1.23",
"typo3/cms-backend": "^9.5.31|^10.4.34",
"typo3/cms-fluid": "^9.5.31|^10.4.34",
"typo3/cms-fluid-styled-content": "^9.5.31|^10.4.34",
"typo3/cms-frontend": "^9.5.31|^10.4.34",
"typo3/testing-framework": "^4.15.5|^6.16.6"
"typo3/testing-framework": "^4.15.5|^6.16.6",
"donatj/mock-webserver": "^2.6"
},
"replace": {
"typo3-ter/dlf": "self.version"
Expand Down

0 comments on commit e19eb0f

Please sign in to comment.