Skip to content

Commit

Permalink
Add Travis-CI to run tests in project
Browse files Browse the repository at this point in the history
  • Loading branch information
DeryabinSergey committed May 24, 2020
1 parent 21fdbdf commit 3e0ca01
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
language: php
services:
- mysql
- postgresql
- redis-server
- memcached
php:
- 7.4.6
before_install:
- yes | pecl install memcache
- no | pecl install memcached
- echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- mysql -e 'CREATE DATABASE onphp;'
- psql -c 'create database onphp;' -U postgres
- cp ./tests/travis.inc.php.tpl ./tests/config.inc.php

install:
- composer update -n

before_script:
- wget https://repo.mysql.com//mysql-apt-config_0.8.15-1_all.deb
- sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb
- sudo apt-get update -q
- sudo apt-get install -q -y --allow-unauthenticated -o Dpkg::Options::=--force-confnew mysql-server
- sudo systemctl restart mysql
- sudo mysql_upgrade
- mysql --version


- sudo apt-get install -q -y apache2 libapache2-mod-fastcgi
- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- sudo a2enmod rewrite actions fastcgi alias
- echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars
- sudo chown -R travis:travis /var/lib/apache2/fastcgi
- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
# configure apache virtual hosts
- sudo cp -f travis/travis-ci-apache /etc/apache2/sites-available/000-default.conf
- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf
- sudo service apache2 restart
#- curl -vsf 'http://localhost/curlTest.php' &> /dev/stdout

script:
- ./vendor/bin/phpunit --exclude-group amqp,cookie,mail,pinba --verbose --dont-report-useless-tests ./tests/AllTests.php
50 changes: 50 additions & 0 deletions tests/travis.inc.php.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

use OnPHP\Core\DB\MySQLim;
use OnPHP\Core\DB\PgSQL;
use OnPHP\Core\DB\SQLitePDO;
use OnPHP\Main\DAO\Handlers\CacheSegmentHandler;
use OnPHP\Main\DAO\Worker\CacheDaoWorker;
use OnPHP\Main\DAO\Worker\CommonDaoWorker;
use OnPHP\Main\DAO\Worker\NullDaoWorker;
use OnPHP\Main\DAO\Worker\SmartDaoWorker;
use OnPHP\Main\DAO\Worker\VoodooDaoWorker;

$dbs = array(
PgSQL::class => array(
'user' => 'postgres',
'pass' => '',
'host' => '127.0.0.1',
'base' => 'onphp'
),
MySQLim::class => array(
'user' => 'root',
'pass' => '',
'host' => 'localhost',
'base' => 'onphp'
),
SQLitePDO::class => array(
'user' => 'onphp',
'pass' => 'onphp',
'host' => '127.0.0.1',
'base' => 'onphp'
),
);

$daoWorkers = array(
VoodooDaoWorker::class,
CommonDaoWorker::class,
SmartDaoWorker::class,
VoodooDaoWorker::class,
CacheDaoWorker::class,
VoodooDaoWorker::class,
SmartDaoWorker::class,
CommonDaoWorker::class,
NullDaoWorker::class
);

VoodooDaoWorker::setDefaultHandler(CacheSegmentHandler::class);

define('__LOCAL_DEBUG__', true);
define('ONPHP_CURL_TEST_URL', 'http://localhost/curlTest.php'); //set here url to test script test/main/data/curlTest/curlTest.php
?>
25 changes: 25 additions & 0 deletions travis/travis-ci-apache
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<VirtualHost *:80>
# [...]

DocumentRoot %TRAVIS_BUILD_DIR%/tests/Main/data/curlTest

<Directory "%TRAVIS_BUILD_DIR%/tests/Main/data/curlTest/">
Options FollowSymLinks MultiViews ExecCGI
AllowOverride All
Require all granted
</Directory>

# Wire up Apache to use Travis CI's php-fpm.
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization

<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</IfModule>

# [...]
</VirtualHost>

0 comments on commit 3e0ca01

Please sign in to comment.