Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-24.04
strategy:
matrix:
php: ['8.1', '8.2']
php: ['8.4']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -24,7 +24,7 @@ jobs:
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s composerValidate

- name: GrumPHP
run: .Build/vendor/phpro/grumphp/bin/grumphp run
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s grumphp

- name: Lint PHP
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s lint
Expand Down
18 changes: 13 additions & 5 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Options:
- composerInstallMax: "composer update", with no platform.php config.
- composerInstallMin: "composer update --prefer-lowest", with platform.php set to PHP version x.x.0.
- composerValidate: "composer validate"
- grumphp: "GrumPHP run"
- lint: PHP linting
- unit (default): PHP unit tests
- functional: functional tests
Expand All @@ -59,12 +60,13 @@ Options:
- postgres: use postgres
- sqlite: use sqlite

-p <7.2|7.3|7.4|8.0>
-p <7.2|7.3|7.4|8.0|8.4>
Specifies the PHP minor version to be used
- 7.2: use PHP 7.2
- 7.3: use PHP 7.3
- 7.4: use PHP 7.4
- 8.0: use PHP 8.0
- 8.4: use PHP 8.4

-e "<phpunit options>"
Only with -s functional|unit
Expand Down Expand Up @@ -256,6 +258,12 @@ case ${TEST_SUITE} in
esac
docker compose down
;;
grumphp)
setUpDockerComposeDotEnv
docker compose run grumphp
SUITE_EXIT_CODE=$?
docker compose down
;;
lint)
setUpDockerComposeDotEnv
docker compose run lint
Expand All @@ -269,10 +277,10 @@ case ${TEST_SUITE} in
docker compose down
;;
update)
# pull typo3/core-testing-*:latest versions of those ones that exist locally
docker images typo3/core-testing-*:latest --format "{{.Repository}}:latest" | xargs -I {} docker pull {}
# remove "dangling" typo3/core-testing-* images (those tagged as <none>)
docker images typo3/core-testing-* --filter "dangling=true" --format "{{.ID}}" | xargs -I {} docker rmi {}
# pull ghcr.io/typo3/core-testing-php-*:latest versions of those ones that exist locally
docker images ghcr.io/typo3/core-testing-php-*:latest --format "{{.Repository}}:latest" | xargs -I {} docker pull {}
# remove "dangling" ghcr.io/typo3/core-testing-php-* images (those tagged as <none>)
docker images ghcr.io/typo3/core-testing-php-* --filter "dangling=true" --format "{{.ID}}" | xargs -I {} docker rmi {}
;;
*)
echo "Invalid -s option argument ${TEST_SUITE}" >&2
Expand Down
38 changes: 28 additions & 10 deletions Build/testing-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
- ../../.Build/minio-data:/minio-data

composer_install:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
image: ghcr.io/typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
Expand All @@ -45,7 +45,7 @@ services:
composer install --no-progress --no-interaction;
"
composer_install_max:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
image: ghcr.io/typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
Expand Down Expand Up @@ -73,7 +73,7 @@ services:
'

composer_install_min:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
image: ghcr.io/typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
Expand Down Expand Up @@ -101,7 +101,7 @@ services:
'

composer_validate:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
image: ghcr.io/typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
Expand All @@ -118,7 +118,7 @@ services:
"

functional_mariadb10:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
image: ghcr.io/typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
links:
- mariadb10
Expand Down Expand Up @@ -157,7 +157,7 @@ services:
"

functional_mssql2019latest:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
image: ghcr.io/typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
links:
- mssql2019latest
Expand Down Expand Up @@ -200,7 +200,7 @@ services:
"

functional_postgres10:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
image: ghcr.io/typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
links:
- postgres10
Expand Down Expand Up @@ -240,7 +240,7 @@ services:
"

functional_sqlite:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
image: ghcr.io/typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
links:
- minio
Expand Down Expand Up @@ -272,8 +272,26 @@ services:
fi
"

grumphp:
image: ghcr.io/typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
- ${HOST_HOME}:${HOST_HOME}
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
set -x
fi
php -v | grep '^PHP';
.Build/vendor/phpro/grumphp/bin/grumphp run;
"

lint:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
image: ghcr.io/typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
Expand All @@ -290,7 +308,7 @@ services:
"

unit:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
image: ghcr.io/typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Driver/AmazonS3Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class AmazonS3Driver extends AbstractHierarchicalFilesystemDriver implements Str
* @param array $configuration
* @param S3Client $s3Client
*/
public function __construct(array $configuration = [], $s3Client = null, EventDispatcherInterface $eventDispatcher = null)
public function __construct(array $configuration = [], $s3Client = null, ?EventDispatcherInterface $eventDispatcher = null)
{
parent::__construct($configuration);
$this->eventDispatcher = $eventDispatcher ?? GeneralUtility::makeInstance(EventDispatcherInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion Classes/S3Adapter/AbstractS3Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AbstractS3Adapter
* AbstractS3Adapter constructor.
* @param S3Client $s3Client
*/
public function __construct(S3Client $s3Client = null)
public function __construct(?S3Client $s3Client = null)
{
$this->s3Client = $s3Client;
}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
tests: unit-tests functional-tests

functional-tests: .Build/bin/phpunit .Build/Web/typo3conf/ext/aus_driver_amazon_s3
./Build/Scripts/runTests.sh -p 8.2 -d sqlite -s functional\
./Build/Scripts/runTests.sh -p 8.4 -d sqlite -s functional\
-e "--display-warnings --display-notices --display-errors"

unit-tests: .Build/bin/phpunit .Build/Web/typo3conf/ext/aus_driver_amazon_s3
./Build/Scripts/runTests.sh -p 8.2 -d sqlite -s unit\
./Build/Scripts/runTests.sh -p 8.4 -d sqlite -s unit\
-e "--display-warnings --display-notices --display-errors"

.Build/bin/phpunit:
Expand Down
30 changes: 12 additions & 18 deletions Tests/Unit/Driver/AmazonS3DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
use Aws\Api\DateTimeResult;
use Aws\Result;
use Aws\S3\S3Client;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Http\Message\ServerRequestInterface;
Expand All @@ -26,6 +28,7 @@
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\EventDispatcher\EventDispatcher;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down Expand Up @@ -98,6 +101,9 @@ public function setUp(): void
]);
$this->s3Client = $this->prophesize(S3Client::class);
$eventDispatcher = $this->prophesize(EventDispatcher::class);
$pageRenderer = $this->prophesize(PageRenderer::class);
$pageRenderer->addHeaderData(Argument::any())->willReturn(null);
GeneralUtility::setSingletonInstance(PageRenderer::class, $pageRenderer->reveal());
$this->driver = new AmazonS3Driver($this->testConfiguration, $this->s3Client->reveal(), $eventDispatcher->reveal());
$this->driver->setStorageUid(42);
$this->driver->initialize();
Expand All @@ -109,9 +115,7 @@ public function tearDown(): void
parent::tearDown();
}

/**
* @test
*/
#[Test]
public function testPublicUrlGetter()
{
$assertedMappings = [
Expand All @@ -126,25 +130,19 @@ public function testPublicUrlGetter()
}
}

/**
* @test
*/
#[Test]
public function testDefaultFolderGetter()
{
$this->assertEquals('/', $this->driver->getDefaultFolder());
}

/**
* @test
*/
#[Test]
public function testRootLevelFolderGetter()
{
$this->assertEquals('/', $this->driver->getRootLevelFolder());
}

/**
* @test
*/
#[Test]
public function testGetFileInfoByIdentifier()
{
$fileIdentifier = 'foo/bar/test.file';
Expand Down Expand Up @@ -177,9 +175,7 @@ public function testGetFileInfoByIdentifier()
$this->assertEquals($this->driver->getStorageUid(), $info['storage']);
}

/**
* @test
*/
#[Test]
public function testGetFileInfoByIdentifierWithLimitedProperties()
{
$fileIdentifier = 'foo/bar/test.file';
Expand All @@ -201,9 +197,7 @@ public function testGetFileInfoByIdentifierWithLimitedProperties()
}


/**
* @test
*/
#[Test]
public function testGetFileInfoByIdentifierWithPseudoMimeType()
{
$fileIdentifier = 'foo/bar/test.youtube';
Expand Down
Loading