Merge pull request #14 from testcontainers/rename

feat: rename package name
This commit is contained in:
Shyim
2024-08-05 21:35:10 +02:00
committed by GitHub
24 changed files with 137 additions and 79 deletions
+44 -11
View File
@@ -2,21 +2,60 @@ name: PHP
on: on:
push: push:
branches: [ "main" ] branches:
- main
pull_request: pull_request:
branches: [ "main" ] branches:
- main
permissions: permissions:
contents: read contents: read
jobs: jobs:
build: cs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Code Style
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Setup PHP with PECL extension - name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run cs
run: composer run cs
phpstan:
runs-on: ubuntu-latest
name: Static Analysis
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run phpstan
run: composer run phpstan
phpunit:
runs-on: ubuntu-latest
name: Integration Tests
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.1' php-version: '8.1'
@@ -27,9 +66,3 @@ jobs:
- name: Run test suite - name: Run test suite
run: composer run integration run: composer run integration
- name: Run cs
run: composer run cs
- name: Run phpstan
run: composer run phpstan
+2 -1
View File
@@ -1,3 +1,4 @@
/vendor/ /vendor/
.php-cs-fixer.cache /.php-cs-fixer.cache
/.phpunit.cache
/composer.lock /composer.lock
+8 -10
View File
@@ -2,14 +2,12 @@
Testcontainers is a PHP package that makes it simple to create and clean up container-based dependencies for automated integration/smoke tests. The package is inspired by the [Testcontainers](https://www.testcontainers.org/) project for Java. Testcontainers is a PHP package that makes it simple to create and clean up container-based dependencies for automated integration/smoke tests. The package is inspired by the [Testcontainers](https://www.testcontainers.org/) project for Java.
[@sironheart](https://github.com/sironheart) has annoyed me to test testcontainers, but it didn't existed in PHP yet.
## Installation ## Installation
Add this to your project with composer Add this to your project with composer
```bash ```bash
composer req --dev shyim/testcontainer composer req --dev testcontainers/testcontainers
``` ```
## Usage/Examples ## Usage/Examples
@@ -19,7 +17,7 @@ composer req --dev shyim/testcontainer
```php ```php
<?php <?php
use Testcontainer\Container\MySQLContainer; use Testcontainers\Container\Container;
$container = Container::make('nginx:alpine'); $container = Container::make('nginx:alpine');
@@ -60,7 +58,7 @@ $container->withWait(new WaitForHealthCheck());
```php ```php
<?php <?php
use Testcontainer\Container\MySQLContainer; use Testcontainers\Container\MySQLContainer;
$container = MySQLContainer::make('8.0'); $container = MySQLContainer::make('8.0');
$container->withMySQLDatabase('foo'); $container->withMySQLDatabase('foo');
@@ -82,7 +80,7 @@ $pdo = new \PDO(
```php ```php
<?php <?php
use Testcontainer\Container\MariaDBContainer; use Testcontainers\Container\MariaDBContainer;
$container = MariaDBContainer::make('8.0'); $container = MariaDBContainer::make('8.0');
$container->withMariaDBDatabase('foo'); $container->withMariaDBDatabase('foo');
@@ -104,7 +102,7 @@ $pdo = new \PDO(
```php ```php
<?php <?php
use Testcontainer\Container\PostgresContainer; use Testcontainers\Container\PostgresContainer;
$container = PostgresContainer::make('15.0', 'password'); $container = PostgresContainer::make('15.0', 'password');
$container->withPostgresDatabase('database'); $container->withPostgresDatabase('database');
@@ -125,7 +123,7 @@ $pdo = new \PDO(
```php ```php
use Testcontainer\Container\RedisContainer; use Testcontainers\Container\RedisContainer;
$container = RedisContainer::make('6.0'); $container = RedisContainer::make('6.0');
@@ -141,7 +139,7 @@ $redis->connect($container->getAddress());
```php ```php
use Testcontainer\Container\OpenSearchContainer; use Testcontainers\Container\OpenSearchContainer;
$container = OpenSearchContainer::make('2'); $container = OpenSearchContainer::make('2');
$container->disableSecurityPlugin(); $container->disableSecurityPlugin();
@@ -168,7 +166,7 @@ use Doctrine\Bundle\DoctrineBundle\ConnectionFactory;
use Doctrine\Common\EventManager; use Doctrine\Common\EventManager;
use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Tools\DsnParser; use Doctrine\DBAL\Tools\DsnParser;
use Testcontainer\Container\PostgresContainer; use Testcontainers\Container\PostgresContainer;
class TestConnectionFactory extends ConnectionFactory class TestConnectionFactory extends ConnectionFactory
{ {
+6 -6
View File
@@ -1,10 +1,10 @@
{ {
"name": "shyim/testcontainer", "name": "testcontainers/testcontainers",
"description": "Testcontainer implementation in PHP", "description": "Testcontainers implementation in PHP",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
"docker", "docker",
"testcontainer" "testcontainers"
], ],
"type": "library", "type": "library",
"authors": [ "authors": [
@@ -15,7 +15,7 @@
], ],
"require": { "require": {
"php": ">= 8.1", "php": ">= 8.1",
"symfony/process": "^5.3|^6.0|^7.0" "symfony/process": "^5.0|^6.0|^7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.5",
@@ -28,12 +28,12 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Testcontainer\\": "src/" "Testcontainers\\": "src/"
} }
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"Testcontainer\\Tests\\": "tests/" "Testcontainers\\Tests\\": "tests/"
} }
}, },
"scripts": { "scripts": {
View File
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
+6 -6
View File
@@ -2,14 +2,14 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Container; namespace Testcontainers\Container;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
use Testcontainer\Exception\ContainerNotReadyException; use Testcontainers\Exception\ContainerNotReadyException;
use Testcontainer\Registry; use Testcontainers\Registry;
use Testcontainer\Trait\DockerContainerAwareTrait; use Testcontainers\Trait\DockerContainerAwareTrait;
use Testcontainer\Wait\WaitForNothing; use Testcontainers\Wait\WaitForNothing;
use Testcontainer\Wait\WaitInterface; use Testcontainers\Wait\WaitInterface;
/** /**
* @phpstan-type ContainerInspectSingleNetwork array<int, array{'NetworkSettings': array{'IPAddress': string}}> * @phpstan-type ContainerInspectSingleNetwork array<int, array{'NetworkSettings': array{'IPAddress': string}}>
+2 -2
View File
@@ -2,9 +2,9 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Container; namespace Testcontainers\Container;
use Testcontainer\Wait\WaitForExec; use Testcontainers\Wait\WaitForExec;
class MariaDBContainer extends Container class MariaDBContainer extends Container
{ {
+2 -2
View File
@@ -2,9 +2,9 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Container; namespace Testcontainers\Container;
use Testcontainer\Wait\WaitForExec; use Testcontainers\Wait\WaitForExec;
class MySQLContainer extends Container class MySQLContainer extends Container
{ {
+2 -2
View File
@@ -2,9 +2,9 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Container; namespace Testcontainers\Container;
use Testcontainer\Wait\WaitForHttp; use Testcontainers\Wait\WaitForHttp;
class OpenSearchContainer extends Container class OpenSearchContainer extends Container
{ {
+2 -2
View File
@@ -2,9 +2,9 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Container; namespace Testcontainers\Container;
use Testcontainer\Wait\WaitForExec; use Testcontainers\Wait\WaitForExec;
class PostgresContainer extends Container class PostgresContainer extends Container
{ {
+2 -2
View File
@@ -2,9 +2,9 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Container; namespace Testcontainers\Container;
use Testcontainer\Wait\WaitForLog; use Testcontainers\Wait\WaitForLog;
class RedisContainer extends Container class RedisContainer extends Container
{ {
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Exception; namespace Testcontainers\Exception;
class ContainerNotReadyException extends \RuntimeException class ContainerNotReadyException extends \RuntimeException
{ {
+2 -2
View File
@@ -2,9 +2,9 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer; namespace Testcontainers;
use Testcontainer\Container\Container; use Testcontainers\Container\Container;
class Registry class Registry
{ {
+2 -2
View File
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Trait; namespace Testcontainers\Trait;
use JsonException; use JsonException;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
use Testcontainer\Container\Container; use Testcontainers\Container\Container;
use UnexpectedValueException; use UnexpectedValueException;
/** /**
+2 -2
View File
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Wait; namespace Testcontainers\Wait;
use Closure; use Closure;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
use Testcontainer\Exception\ContainerNotReadyException; use Testcontainers\Exception\ContainerNotReadyException;
class WaitForExec implements WaitInterface class WaitForExec implements WaitInterface
{ {
+2 -2
View File
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Wait; namespace Testcontainers\Wait;
use RuntimeException; use RuntimeException;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
use Testcontainer\Exception\ContainerNotReadyException; use Testcontainers\Exception\ContainerNotReadyException;
class WaitForHealthCheck implements WaitInterface class WaitForHealthCheck implements WaitInterface
{ {
+3 -3
View File
@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Wait; namespace Testcontainers\Wait;
use Testcontainer\Exception\ContainerNotReadyException; use Testcontainers\Exception\ContainerNotReadyException;
use Testcontainer\Trait\DockerContainerAwareTrait; use Testcontainers\Trait\DockerContainerAwareTrait;
class WaitForHttp implements WaitInterface class WaitForHttp implements WaitInterface
{ {
+2 -2
View File
@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Wait; namespace Testcontainers\Wait;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
use Testcontainer\Exception\ContainerNotReadyException; use Testcontainers\Exception\ContainerNotReadyException;
class WaitForLog implements WaitInterface class WaitForLog implements WaitInterface
{ {
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Wait; namespace Testcontainers\Wait;
class WaitForNothing implements WaitInterface class WaitForNothing implements WaitInterface
{ {
+3 -3
View File
@@ -2,12 +2,12 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Wait; namespace Testcontainers\Wait;
use JsonException; use JsonException;
use RuntimeException; use RuntimeException;
use Testcontainer\Exception\ContainerNotReadyException; use Testcontainers\Exception\ContainerNotReadyException;
use Testcontainer\Trait\DockerContainerAwareTrait; use Testcontainers\Trait\DockerContainerAwareTrait;
final class WaitForTcpPortOpen implements WaitInterface final class WaitForTcpPortOpen implements WaitInterface
{ {
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Wait; namespace Testcontainers\Wait;
interface WaitInterface interface WaitInterface
{ {
+6 -6
View File
@@ -2,15 +2,15 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Tests\Integration; namespace Testcontainers\Tests\Integration;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Predis\Client; use Predis\Client;
use Testcontainer\Container\MariaDBContainer; use Testcontainers\Container\MariaDBContainer;
use Testcontainer\Container\MySQLContainer; use Testcontainers\Container\MySQLContainer;
use Testcontainer\Container\OpenSearchContainer; use Testcontainers\Container\OpenSearchContainer;
use Testcontainer\Container\PostgresContainer; use Testcontainers\Container\PostgresContainer;
use Testcontainer\Container\RedisContainer; use Testcontainers\Container\RedisContainer;
class ContainerTest extends TestCase class ContainerTest extends TestCase
{ {
+10 -10
View File
@@ -2,21 +2,21 @@
declare(strict_types=1); declare(strict_types=1);
namespace Testcontainer\Tests\Integration; namespace Testcontainers\Tests\Integration;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Predis\Client; use Predis\Client;
use Predis\Connection\ConnectionException; use Predis\Connection\ConnectionException;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
use Testcontainer\Container\Container; use Testcontainers\Container\Container;
use Testcontainer\Exception\ContainerNotReadyException; use Testcontainers\Exception\ContainerNotReadyException;
use Testcontainer\Registry; use Testcontainers\Registry;
use Testcontainer\Trait\DockerContainerAwareTrait; use Testcontainers\Trait\DockerContainerAwareTrait;
use Testcontainer\Wait\WaitForExec; use Testcontainers\Wait\WaitForExec;
use Testcontainer\Wait\WaitForHealthCheck; use Testcontainers\Wait\WaitForHealthCheck;
use Testcontainer\Wait\WaitForHttp; use Testcontainers\Wait\WaitForHttp;
use Testcontainer\Wait\WaitForLog; use Testcontainers\Wait\WaitForLog;
use Testcontainer\Wait\WaitForTcpPortOpen; use Testcontainers\Wait\WaitForTcpPortOpen;
class WaitStrategyTest extends TestCase class WaitStrategyTest extends TestCase
{ {