Skip to content

Commit

Permalink
added dockerized test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
schmunk42 committed Jan 10, 2017
1 parent 6d277dd commit f9072cc
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 5 deletions.
42 changes: 42 additions & 0 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM codeception/codeception

# Install system packages for PHP extensions recommended for Yii 2.0 Framework
RUN curl -sL https://deb.nodesource.com/setup_4.x | bash - && \
apt-key update && \
apt-get update && \
apt-get -y install \
g++ \
git \
libicu-dev \
libmcrypt-dev \
libfreetype6-dev \
libjpeg-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libpq5 \
libpq-dev \
zlib1g-dev \
mysql-client \
openssh-client \
libxml2-dev \
--no-install-recommends && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install PHP extensions required for Yii 2.0 Framework
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/ && \
docker-php-ext-configure bcmath && \
docker-php-ext-install \
#pdo_sqlsrv \
#pdo_cubrid \
#pdo_oci \
gd \
intl \
pdo_mysql \
pdo_pgsql \
mbstring \
mcrypt \
zip \
bcmath \
soap
15 changes: 15 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,18 @@ contain the following:
$config['databases']['mysql']['username'] = 'yiitest';
$config['databases']['mysql']['password'] = 'changeme';
```


DOCKER
------

WIP

Start test stack and enter yii/test container

docker-compose up -d
docker-compose run --rm test

Run unit tests

$ vendor/bin/phpunit -v --debug tests/framework/db
10 changes: 5 additions & 5 deletions tests/data/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@
$config = [
'databases' => [
'cubrid' => [
'dsn' => 'cubrid:dbname=demodb;host=localhost;port=33000',
'dsn' => 'cubrid:dbname=demodb;host=cubrid;port=33000',
'username' => 'dba',
'password' => '',
'fixture' => __DIR__ . '/cubrid.sql',
],
'mysql' => [
'dsn' => 'mysql:host=127.0.0.1;dbname=yiitest',
'dsn' => 'mysql:host=mysql;dbname=yiitest',
'username' => 'travis',
'password' => '',
'password' => 'travis',
'fixture' => __DIR__ . '/mysql.sql',
],
'sqlite' => [
'dsn' => 'sqlite::memory:',
'fixture' => __DIR__ . '/sqlite.sql',
],
'sqlsrv' => [
'dsn' => 'sqlsrv:Server=localhost;Database=test',
'dsn' => 'sqlsrv:Server=sqlsrv;Database=test',
'username' => '',
'password' => '',
'fixture' => __DIR__ . '/mssql.sql',
],
'pgsql' => [
'dsn' => 'pgsql:host=localhost;dbname=yiitest;port=5432;',
'dsn' => 'pgsql:host=postgres;dbname=yiitest;port=5432;',
'username' => 'postgres',
'password' => 'postgres',
'fixture' => __DIR__ . '/postgres.sql',
Expand Down
32 changes: 32 additions & 0 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '2'
services:

test:
build: .
entrypoint: bash
depends_on:
- postgres
- mysql
volumes:
- ../:/project

mysql:
image: percona:5.7
environment:
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_DATABASE=yiitest
- MYSQL_USER=travis
- MYSQL_PASSWORD=travis

postgres:
image: postgres
environment:
- POSTGRES_DB=yiitest
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres

#sqlsrv:
# image: microsoft/mssql-server-linux

#cubrid:
# image: lighthopper/cubrid

0 comments on commit f9072cc

Please sign in to comment.