Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rename package name #14

Merged
merged 2 commits into from
Aug 5, 2024
Merged
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
53 changes: 43 additions & 10 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,67 @@ name: PHP

on:
push:
branches: [ "main" ]
branches:
- main
pull_request:
branches: [ "main" ]
branches:
- main

permissions:
contents: read

jobs:
build:
cs:
runs-on: ubuntu-latest
name: Code Style

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'
extensions: redis, pgsql

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run integration

- 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
with:
php-version: '8.1'
extensions: redis, pgsql

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run integration
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
.php-cs-fixer.cache
/.php-cs-fixer.cache
/.phpunit.cache
/composer.lock
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

[@sironheart](https://github.com/sironheart) has annoyed me to test testcontainers, but it didn't existed in PHP yet.

## Installation

Add this to your project with composer

```bash
composer req --dev shyim/testcontainer
composer req --dev testcontainers/testcontainers
```

## Usage/Examples
Expand All @@ -19,7 +17,7 @@ composer req --dev shyim/testcontainer
```php
<?php

use Testcontainer\Container\MySQLContainer;
use Testcontainers\Container\Container;

$container = Container::make('nginx:alpine');

Expand Down Expand Up @@ -60,7 +58,7 @@ $container->withWait(new WaitForHealthCheck());
```php
<?php

use Testcontainer\Container\MySQLContainer;
use Testcontainers\Container\MySQLContainer;

$container = MySQLContainer::make('8.0');
$container->withMySQLDatabase('foo');
Expand All @@ -82,7 +80,7 @@ $pdo = new \PDO(
```php
<?php

use Testcontainer\Container\MariaDBContainer;
use Testcontainers\Container\MariaDBContainer;

$container = MariaDBContainer::make('8.0');
$container->withMariaDBDatabase('foo');
Expand All @@ -104,7 +102,7 @@ $pdo = new \PDO(
```php
<?php

use Testcontainer\Container\PostgresContainer;
use Testcontainers\Container\PostgresContainer;

$container = PostgresContainer::make('15.0', 'password');
$container->withPostgresDatabase('database');
Expand All @@ -125,7 +123,7 @@ $pdo = new \PDO(

```php

use Testcontainer\Container\RedisContainer;
use Testcontainers\Container\RedisContainer;

$container = RedisContainer::make('6.0');

Expand All @@ -141,7 +139,7 @@ $redis->connect($container->getAddress());

```php

use Testcontainer\Container\OpenSearchContainer;
use Testcontainers\Container\OpenSearchContainer;

$container = OpenSearchContainer::make('2');
$container->disableSecurityPlugin();
Expand All @@ -168,7 +166,7 @@ use Doctrine\Bundle\DoctrineBundle\ConnectionFactory;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Tools\DsnParser;
use Testcontainer\Container\PostgresContainer;
use Testcontainers\Container\PostgresContainer;

class TestConnectionFactory extends ConnectionFactory
{
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "shyim/testcontainer",
"description": "Testcontainer implementation in PHP",
"name": "testcontainers/testcontainers",
"description": "Testcontainers implementation in PHP",
"license": "MIT",
"keywords": [
"docker",
"testcontainer"
"testcontainers"
],
"type": "library",
"authors": [
Expand All @@ -15,7 +15,7 @@
],
"require": {
"php": ">= 8.1",
"symfony/process": "^5.3|^6.0|^7.0"
"symfony/process": "^5.0|^6.0|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
Expand All @@ -28,12 +28,12 @@
},
"autoload": {
"psr-4": {
"Testcontainer\\": "src/"
"Testcontainers\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Testcontainer\\Tests\\": "tests/"
"Testcontainers\\Tests\\": "tests/"
}
},
"scripts": {
Expand Down
File renamed without changes.
26 changes: 26 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -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>
12 changes: 6 additions & 6 deletions src/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

namespace Testcontainer\Container;
namespace Testcontainers\Container;

use Symfony\Component\Process\Process;
use Testcontainer\Exception\ContainerNotReadyException;
use Testcontainer\Registry;
use Testcontainer\Trait\DockerContainerAwareTrait;
use Testcontainer\Wait\WaitForNothing;
use Testcontainer\Wait\WaitInterface;
use Testcontainers\Exception\ContainerNotReadyException;
use Testcontainers\Registry;
use Testcontainers\Trait\DockerContainerAwareTrait;
use Testcontainers\Wait\WaitForNothing;
use Testcontainers\Wait\WaitInterface;

/**
* @phpstan-type ContainerInspectSingleNetwork array<int, array{'NetworkSettings': array{'IPAddress': string}}>
Expand Down
4 changes: 2 additions & 2 deletions src/Container/MariaDBContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Testcontainer\Container;
namespace Testcontainers\Container;

use Testcontainer\Wait\WaitForExec;
use Testcontainers\Wait\WaitForExec;

class MariaDBContainer extends Container
{
Expand Down
4 changes: 2 additions & 2 deletions src/Container/MySQLContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Testcontainer\Container;
namespace Testcontainers\Container;

use Testcontainer\Wait\WaitForExec;
use Testcontainers\Wait\WaitForExec;

class MySQLContainer extends Container
{
Expand Down
4 changes: 2 additions & 2 deletions src/Container/OpenSearchContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Testcontainer\Container;
namespace Testcontainers\Container;

use Testcontainer\Wait\WaitForHttp;
use Testcontainers\Wait\WaitForHttp;

class OpenSearchContainer extends Container
{
Expand Down
4 changes: 2 additions & 2 deletions src/Container/PostgresContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Testcontainer\Container;
namespace Testcontainers\Container;

use Testcontainer\Wait\WaitForExec;
use Testcontainers\Wait\WaitForExec;

class PostgresContainer extends Container
{
Expand Down
4 changes: 2 additions & 2 deletions src/Container/RedisContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Testcontainer\Container;
namespace Testcontainers\Container;

use Testcontainer\Wait\WaitForLog;
use Testcontainers\Wait\WaitForLog;

class RedisContainer extends Container
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ContainerNotReadyException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Testcontainer\Exception;
namespace Testcontainers\Exception;

class ContainerNotReadyException extends \RuntimeException
{
Expand Down
4 changes: 2 additions & 2 deletions src/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Testcontainer;
namespace Testcontainers;

use Testcontainer\Container\Container;
use Testcontainers\Container\Container;

class Registry
{
Expand Down
4 changes: 2 additions & 2 deletions src/Trait/DockerContainerAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Testcontainer\Trait;
namespace Testcontainers\Trait;

use JsonException;
use Symfony\Component\Process\Process;
use Testcontainer\Container\Container;
use Testcontainers\Container\Container;
use UnexpectedValueException;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Wait/WaitForExec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Testcontainer\Wait;
namespace Testcontainers\Wait;

use Closure;
use Symfony\Component\Process\Process;
use Testcontainer\Exception\ContainerNotReadyException;
use Testcontainers\Exception\ContainerNotReadyException;

class WaitForExec implements WaitInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/Wait/WaitForHealthCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Testcontainer\Wait;
namespace Testcontainers\Wait;

use RuntimeException;
use Symfony\Component\Process\Process;
use Testcontainer\Exception\ContainerNotReadyException;
use Testcontainers\Exception\ContainerNotReadyException;

class WaitForHealthCheck implements WaitInterface
{
Expand Down
6 changes: 3 additions & 3 deletions src/Wait/WaitForHttp.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace Testcontainer\Wait;
namespace Testcontainers\Wait;

use Testcontainer\Exception\ContainerNotReadyException;
use Testcontainer\Trait\DockerContainerAwareTrait;
use Testcontainers\Exception\ContainerNotReadyException;
use Testcontainers\Trait\DockerContainerAwareTrait;

class WaitForHttp implements WaitInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/Wait/WaitForLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace Testcontainer\Wait;
namespace Testcontainers\Wait;

use Symfony\Component\Process\Process;
use Testcontainer\Exception\ContainerNotReadyException;
use Testcontainers\Exception\ContainerNotReadyException;

class WaitForLog implements WaitInterface
{
Expand Down
Loading