Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Jan 17, 2024
1 parent a263248 commit a6ba499
Show file tree
Hide file tree
Showing 28 changed files with 284 additions and 141 deletions.
15 changes: 15 additions & 0 deletions .docker/php81.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM php:8.1-cli

RUN apt-get update && \
apt-get install -y libpq-dev && \
docker-php-ext-install pdo_mysql pdo_pgsql

RUN apt-get -y install gpg && \
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg && \
curl https://packages.microsoft.com/config/debian/12/prod.list | tee /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get -y install msodbcsql18 unixodbc-dev && \
pecl install sqlsrv pdo_sqlsrv && \
docker-php-ext-enable sqlsrv pdo_sqlsrv

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
15 changes: 15 additions & 0 deletions .docker/php82.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM php:8.2-cli

RUN apt-get update && \
apt-get install -y libpq-dev && \
docker-php-ext-install pdo_mysql pdo_pgsql

RUN apt-get -y install gpg && \
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg && \
curl https://packages.microsoft.com/config/debian/12/prod.list | tee /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get -y install msodbcsql18 unixodbc-dev && \
pecl install sqlsrv pdo_sqlsrv && \
docker-php-ext-enable sqlsrv pdo_sqlsrv

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
15 changes: 15 additions & 0 deletions .docker/php83.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM php:8.3-cli

RUN apt-get update && \
apt-get install -y libpq-dev && \
docker-php-ext-install pdo_mysql pdo_pgsql

RUN apt-get -y install gpg && \
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg && \
curl https://packages.microsoft.com/config/debian/12/prod.list | tee /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get -y install msodbcsql18 unixodbc-dev && \
pecl install sqlsrv pdo_sqlsrv && \
docker-php-ext-enable sqlsrv pdo_sqlsrv

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
16 changes: 9 additions & 7 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/.github export-ignore
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
phpstan.neon.dist export-ignore
phpunit.xml.dist export-ignore
/.docker export-ignore
/.github export-ignore
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
docker-compose.yml export-ignore
phpstan.neon.dist export-ignore
phpunit.xml.dist export-ignore
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
PHPUNIT_FLAGS=$([ "${{ matrix.coverage }}" == "xdebug" ] && echo "--coverage-clover=coverage.xml" || echo "")
vendor/bin/phpunit $PHPUNIT_FLAGS
env:
DATABASE: ${{ matrix.database }}
DB_CONNECTION: ${{ matrix.database }}
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
MARIADB_PORT: ${{ job.services.mariadb.ports[3306] }}
PGSQL_PORT: ${{ job.services.pgsql.ports[5432] }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/vendor
.php-cs-fixer.cache
composer.lock
docker-compose.override.yml
80 changes: 80 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
version: '3.8'

services:
php81:
build:
context: .
dockerfile: .docker/php81.Dockerfile
container_name: php81
working_dir: /var/www/html
networks:
- test
volumes:
- .:/var/www/html:delegated
php82:
build:
context: .
dockerfile: .docker/php82.Dockerfile
container_name: php82
working_dir: /var/www/html
networks:
- test
volumes:
- .:/var/www/html:delegated
php83:
build:
context: .
dockerfile: .docker/php83.Dockerfile
container_name: php83
working_dir: /var/www/html
networks:
- test
volumes:
- .:/var/www/html:delegated
mysql:
image: 'mysql:latest'
ports:
- '33060:3306'
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: test
networks:
- test
mariadb:
image: 'mariadb:latest'
ports:
- '33061:3306'
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: test
networks:
- test
pgsql:
image: 'postgres:latest'
ports:
- '5432:5432'
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: test
networks:
- test
sqlsrv:
image: 'mcr.microsoft.com/mssql/server:2019-latest'
ports:
- '1433:1433'
environment:
ACCEPT_EULA: Y
SA_PASSWORD: Password!
healthcheck:
test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$${SA_PASSWORD}" -Q "SELECT 1" -b -o /dev/null
interval: 10s
timeout: 3s
retries: 10
start_period: 10s
networks:
- test

networks:
test:
driver: bridge
36 changes: 18 additions & 18 deletions tests/Graph/AncestorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testLazyLoading()
#[DataProvider(methodName: 'cycleDetectionClassProvider')]
public function testLazyLoadingWithCycleDetection(string $class, array $exclusions)
{
if (in_array($this->database, $exclusions)) {
if (in_array($this->connection, $exclusions)) {
$this->markTestSkipped();
}

Expand All @@ -56,7 +56,7 @@ public function testLazyLoadingWithCycleDetection(string $class, array $exclusio
#[DataProvider(methodName: 'cycleDetectionAndStartClassProvider')]
public function testLazyLoadingWithCycleDetectionAndStart(string $class, array $exclusions)
{
if (in_array($this->database, $exclusions)) {
if (in_array($this->connection, $exclusions)) {
$this->markTestSkipped();
}

Expand All @@ -71,7 +71,7 @@ public function testLazyLoadingWithCycleDetectionAndStart(string $class, array $

public function testLazyLoadingAndSelf()
{
if ($this->database === 'sqlsrv') {
if ($this->connection === 'sqlsrv') {
$this->markTestSkipped();
}

Expand Down Expand Up @@ -113,7 +113,7 @@ public function testLazyLoadingAndSelf()

public function testLazyLoadingAndSelfWithCycleDetection()
{
if ($this->database === 'sqlsrv') {
if ($this->connection === 'sqlsrv') {
$this->markTestSkipped();
}

Expand All @@ -127,7 +127,7 @@ public function testLazyLoadingAndSelfWithCycleDetection()

public function testLazyLoadingAndSelfWithCycleDetectionAndStart()
{
if ($this->database === 'sqlsrv') {
if ($this->connection === 'sqlsrv') {
$this->markTestSkipped();
}

Expand Down Expand Up @@ -167,7 +167,7 @@ public function testEagerLoading()
#[DataProvider(methodName: 'cycleDetectionClassProvider')]
public function testEagerLoadingWithCycleDetection(string $class, array $exclusions)
{
if (in_array($this->database, $exclusions)) {
if (in_array($this->connection, $exclusions)) {
$this->markTestSkipped();
}

Expand All @@ -184,7 +184,7 @@ public function testEagerLoadingWithCycleDetection(string $class, array $exclusi
#[DataProvider(methodName: 'cycleDetectionAndStartClassProvider')]
public function testEagerLoadingWithCycleDetectionAndStart(string $class, array $exclusions)
{
if (in_array($this->database, $exclusions)) {
if (in_array($this->connection, $exclusions)) {
$this->markTestSkipped();
}

Expand All @@ -201,7 +201,7 @@ public function testEagerLoadingWithCycleDetectionAndStart(string $class, array

public function testEagerLoadingAndSelf()
{
if ($this->database === 'sqlsrv') {
if ($this->connection === 'sqlsrv') {
$this->markTestSkipped();
}

Expand Down Expand Up @@ -240,7 +240,7 @@ public function testEagerLoadingAndSelf()

public function testEagerLoadingAndSelfWithCycleDetection()
{
if ($this->database === 'sqlsrv') {
if ($this->connection === 'sqlsrv') {
$this->markTestSkipped();
}

Expand All @@ -254,7 +254,7 @@ public function testEagerLoadingAndSelfWithCycleDetection()

public function testEagerLoadingAndSelfWithCycleDetectionAndStart()
{
if ($this->database === 'sqlsrv') {
if ($this->connection === 'sqlsrv') {
$this->markTestSkipped();
}

Expand Down Expand Up @@ -293,7 +293,7 @@ public function testLazyEagerLoading()

public function testLazyEagerLoadingAndSelf()
{
if ($this->database === 'sqlsrv') {
if ($this->connection === 'sqlsrv') {
$this->markTestSkipped();
}

Expand Down Expand Up @@ -332,7 +332,7 @@ public function testLazyEagerLoadingAndSelf()

public function testExistenceQuery()
{
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
if (in_array($this->connection, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -343,7 +343,7 @@ public function testExistenceQuery()

public function testExistenceQueryAndSelf()
{
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
if (in_array($this->connection, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -354,7 +354,7 @@ public function testExistenceQueryAndSelf()

public function testExistenceQueryForSelfRelation()
{
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
if (in_array($this->connection, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -365,7 +365,7 @@ public function testExistenceQueryForSelfRelation()

public function testExistenceQueryForSelfRelationAndSelf()
{
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
if (in_array($this->connection, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -376,7 +376,7 @@ public function testExistenceQueryForSelfRelationAndSelf()

public function testWithSumForSelfRelation()
{
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
if (in_array($this->connection, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -387,7 +387,7 @@ public function testWithSumForSelfRelation()

public function testWithSumForSelfRelationAndSelf()
{
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
if (in_array($this->connection, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -398,7 +398,7 @@ public function testWithSumForSelfRelationAndSelf()

public function testDelete()
{
if ($this->database === 'mariadb') {
if ($this->connection === 'mariadb') {
$this->markTestSkipped();
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Graph/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CollectionTest extends TestCase
{
public function testToTree()
{
if ($this->database === 'sqlsrv') {
if ($this->connection === 'sqlsrv') {
$this->markTestSkipped();
}

Expand Down Expand Up @@ -41,7 +41,7 @@ public function testToTreeWithRelationship()

public function testToTreeWithCycle()
{
if ($this->database === 'sqlsrv') {
if ($this->connection === 'sqlsrv') {
$this->markTestSkipped();
}

Expand All @@ -61,7 +61,7 @@ public function testToTreeWithCycle()

public function testToTreeWithCycleAndStart()
{
if ($this->database === 'sqlsrv') {
if ($this->connection === 'sqlsrv') {
$this->markTestSkipped();
}

Expand All @@ -81,7 +81,7 @@ public function testToTreeWithCycleAndStart()

public function testToTreeWithEmptyCollection()
{
if ($this->database === 'sqlsrv') {
if ($this->connection === 'sqlsrv') {
$this->markTestSkipped();
}

Expand Down
Loading

0 comments on commit a6ba499

Please sign in to comment.