Skip to content
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/Robofile.php export-ignore
/*.md export-ignore
/*.yml export-ignore
/*.Dockerfile export-ignore
42 changes: 42 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "3.9"

services:

php74:
image: codeception-module-db-php74:2.2.0
build:
context: .
dockerfile: ./php74.Dockerfile
environment:
MYSQL_DSN: "mysql:host=host.docker.internal;port=3102;dbname=codeception"
MYSQL_USER: root
MYSQL_PASSWORD: codeception
XDEBUG_MODE: "debug"
XDEBUG_CONFIG: "client_host=host.docker.internal; client_port=9000; mode=debug; start_wih_request=1"
PHP_IDE_CONFIG: "serverName=codeception-module-db" # the name must be the same as in your PHP -> Server -> "name" field
volumes:
- ".:/var/www/html"

php81:
image: codeception-module-db-php81:2.2.0
build:
context: .
dockerfile: ./php81.Dockerfile
environment:
MYSQL_DSN: "mysql:host=host.docker.internal;port=3102;dbname=codeception"
MYSQL_USER: root
MYSQL_PASSWORD: codeception
XDEBUG_MODE: "debug"
XDEBUG_CONFIG: "client_host=host.docker.internal; client_port=9000; mode=debug; start_wih_request=1"
PHP_IDE_CONFIG: "serverName=codeception-module-db" # the name must be the same as in your PHP -> Server -> "name" field
volumes:
- ".:/var/www/html"

mariadb105:
image: mariadb:10.5
environment:
MARIADB_ROOT_PASSWORD: codeception
MARIADB_DATABASE: codeception
ports:
- "3102:3306"

33 changes: 33 additions & 0 deletions php74.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM php:7.4-cli

RUN apt-get update && \
apt-get install -y \
unzip \
wget \
git \
zlib1g-dev \
libzip-dev \
mariadb-client-10.5

RUN docker-php-ext-install pdo pdo_mysql && docker-php-ext-enable pdo pdo_mysql
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
RUN docker-php-ext-install zip

RUN pecl install xdebug-3.1.5 && \
echo zend_extension=xdebug.so > $PHP_INI_DIR/conf.d/xdebug.ini

COPY --from=composer /usr/bin/composer /usr/bin/composer

WORKDIR /var/www/html

COPY composer.json .
COPY composer.lock .

RUN composer install --no-autoloader

COPY . .

RUN composer dump-autoload -o

ENTRYPOINT ["tail"]
CMD ["-f", "/dev/null"]
33 changes: 33 additions & 0 deletions php81.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM php:8.1-cli

RUN apt-get update && \
apt-get install -y \
unzip \
wget \
git \
zlib1g-dev \
libzip-dev \
mariadb-client-10.5

RUN docker-php-ext-install pdo pdo_mysql && docker-php-ext-enable pdo pdo_mysql
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
RUN docker-php-ext-install zip

RUN pecl install xdebug-3.1.5 && \
echo zend_extension=xdebug.so > $PHP_INI_DIR/conf.d/xdebug.ini

COPY --from=composer /usr/bin/composer /usr/bin/composer

WORKDIR /var/www/html

COPY composer.json .
COPY composer.lock .

RUN composer install --no-autoloader

COPY . .

RUN composer dump-autoload -o

ENTRYPOINT ["tail"]
CMD ["-f", "/dev/null"]
6 changes: 4 additions & 2 deletions tests/unit/Codeception/Module/Db/MySqlDbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ public function getPopulator(): string
public function getConfig(): array
{
$host = getenv('MYSQL_HOST') ? getenv('MYSQL_HOST') : 'localhost';
$user = getenv('MYSQL_USER') ? getenv('MYSQL_USER') : 'root';
$password = getenv('MYSQL_PASSWORD') ? getenv('MYSQL_PASSWORD') : '';
$dsn = getenv('MYSQL_DSN') ? getenv('MYSQL_DSN') : 'mysql:host='.$host.';dbname=codeception_test';

return [
'dsn' => 'mysql:host='.$host.';dbname=codeception_test',
'user' => 'root',
'dsn' => $dsn,
'user' => $user,
'password' => $password,
'dump' => 'tests/data/dumps/mysql.sql',
'reconnect' => true,
Expand Down