Skip to content
Closed
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
5 changes: 5 additions & 0 deletions .ci/mysql_fixtures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

echo "Configure MySQL test database"

mysql --user=root --password=Password123 -e "create database laminasdb_test;"
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
/.laminas-ci.json export-ignore
/phpunit.xml.dist export-ignore
/test/ export-ignore
/clover.xml export-ignore
/clover.xml export-ignore
/vendor/
5 changes: 0 additions & 5 deletions .laminas-ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
{
"name": "PHPUnit",
"php": "8.1"
},
{
"name": "PHPUnit",
"php": "8.4",
"dependencies": "lowest"
}
]
}
3 changes: 3 additions & 0 deletions .laminas-ci/mysql_permissions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE USER 'gha'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'gha'@'%';
FLUSH PRIVILEGES;
29 changes: 29 additions & 0 deletions .laminas-ci/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
requireCoverageMetadata="true"
colors="true">

<extensions>
<bootstrap class="LaminasIntegrationTest\Db\Mysql\Extension\ListenerExtension" />
</extensions>
<testsuites>
<testsuite name="unit test">
<directory>./test/unit</directory>
</testsuite>
<testsuite name="integration test">
<directory>./test/integration</directory>
</testsuite>
</testsuites>
<php>
<!-- Integration Test Variables -->
<env name="TESTS_LAMINAS_DB_MYSQL_ADAPTER" value="true" /><!-- todo: remove this env variable as its no longer needed-->
<env name="TESTS_LAMINAS_DB_MYSQL_ADAPTER_HOSTNAME" value="mysql" />
<env name="TESTS_LAMINAS_DB_MYSQL_ADAPTER_USERNAME" value="gha" />
<env name="TESTS_LAMINAS_DB_MYSQL_ADAPTER_PASSWORD" value="password" />
<env name="TESTS_LAMINAS_DB_MYSQL_ADAPTER_DATABASE" value="laminasdb_test" />
</php>
</phpunit>

17 changes: 17 additions & 0 deletions .laminas-ci/pre-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

WORKING_DIRECTORY=$2
JOB=$3
PHP_VERSION=$(echo "${JOB}" | jq -r '.php')


if [ ! -z "$GITHUB_BASE_REF" ] && [[ "$GITHUB_BASE_REF" =~ ^[0-9]+\.[0-9] ]]; then
readarray -td. TARGET_BRANCH_VERSION_PARTS <<<"${GITHUB_BASE_REF}.";
unset 'TARGET_BRANCH_VERSION_PARTS[-1]';
declare -a TARGET_BRANCH_VERSION_PARTS
MAJOR_OF_TARGET_BRANCH=${TARGET_BRANCH_VERSION_PARTS[0]}
MINOR_OF_TARGET_BRANCH=${TARGET_BRANCH_VERSION_PARTS[1]}

export COMPOSER_ROOT_VERISON="${MAJOR_OF_TARGET_BRANCH}.${MINOR_OF_TARGET_BRANCH}.99"
echo "Exported COMPOSER_ROOT_VERISON as ${COMPOSER_ROOT_VERISON}"
fi
22 changes: 22 additions & 0 deletions .laminas-ci/pre-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

TEST_USER=$1
WORKSPACE=$2
JOB=$3

COMMAND=$(echo "${JOB}" | jq -r '.command')

if [[ ! ${COMMAND} =~ phpunit ]]; then
exit 0
fi

PHP_VERSION=$(echo "${JOB}" | jq -r '.php')

# Install CI version of phpunit config
cp .laminas-ci/phpunit.xml phpunit.xml

# Install lsof (used in integration tests)
apt update -qq
apt install -yqq lsof
23 changes: 23 additions & 0 deletions .psr-container.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* File named as .stub to avoid duplicate declaration of the interface in consuming projects
*/
declare(strict_types=1);

namespace Psr\Container {
/**
* Provides automatic type inference for Psalm when retrieving a service from a container using a FQCN
*/
interface ContainerInterface
{
/** @param string|class-string $id */
public function has(string $id): bool;

/**
* @template T of object
* @psalm-param string|class-string<T> $id
* @psalm-return ($id is class-string ? T : mixed)
*/
public function get(string $id): mixed;
}
}
7 changes: 7 additions & 0 deletions bin/install-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

/usr/bin/composer validate && \
/usr/bin/composer --ignore-platform-reqs install \
--no-ansi --no-progress --no-scripts \
--classmap-authoritative --no-interaction \
--quiet
31 changes: 31 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:
php:
build:
context: ./
dockerfile: docker/php/Dockerfile
args:
- PHP_VERSION=${PHP_VERSION:-8.3.19}
volumes:
- ./:/var/www/html
depends_on:
- mysql

mysql:
build:
context: ./
dockerfile: docker/databases/mysql/Dockerfile
args:
- VERSION=${MYSQL_VERSION:-8.0.41}
ports:
- "3306:3306"
environment:
- MYSQL_DATABASE=${MYSQL_DATABASE:-laminasdb_test}
- MYSQL_USER=${MYSQL_USER:-user}
- MYSQL_PASSWORD=${MYSQL_PASSWORD:-password}
- MYSQL_RANDOM_ROOT_PASSWORD=${MYSQL_RANDOM_ROOT_PASSWORD:-yes}
volumes:
- ./test/integration/TestFixtures/mysql.sql:/docker-entrypoint-initdb.d/mysql.sql
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 20s
retries: 10
19 changes: 12 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"keywords": [
"laminas",
"mysql",
"mysqli",
"pdo",
"db"
],
"homepage": "https://github.com/axleus/laminas-db-mysql/discussions",
Expand All @@ -26,22 +28,28 @@
},
"extra": {
"laminas": {
"component": "Laminas\\Db\\Mysql",
"component": "Laminas\\Db\\Mysql\\Adapter",
"config-provider": "Laminas\\Db\\Mysql\\ConfigProvider"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/axleus/laminas-db"
}
],
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"laminas/laminas-db": "3.0.x"
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0"
},
"require-dev": {
"ext-mysqli": "*",
"ext-pdo_mysql": "*",
"laminas/laminas-coding-standard": "^3.0.1",
"laminas/laminas-db": "dev-phpunit-test",
"laminas/laminas-eventmanager": "^3.6.0",
"laminas/laminas-hydrator": "^4.7",
"laminas/laminas-servicemanager": "^3.19.0",
"phpunit/phpunit": "^9.5.25",
"phpunit/phpunit": "^11.5.15",
"psalm/plugin-phpunit": "^0.19.2",
"vimeo/psalm": "^6.8.8"
},
Expand Down Expand Up @@ -73,8 +81,5 @@
"test-integration": "phpunit --colors=always --testsuite \"integration test\"",
"static-analysis": "psalm --shepherd --stats",
"upload-coverage": "coveralls -v"
},
"conflict": {
"laminas/laminas-db": "*"
}
}
Loading
Loading