Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Commit 76059b1

Browse files
committed
Added basic tests, more will come later
1 parent 1626390 commit 76059b1

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed

.travis.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#
2+
# This file is part of phpFastCache.
3+
#
4+
# @license MIT License (MIT)
5+
#
6+
# For full copyright and license information, please see the docs/CREDITS.txt file.
7+
#
8+
# @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
9+
# @author Georges.L (Geolim4) <contact@geolim4.com>
10+
#
11+
sudo: false
12+
13+
language: php
14+
15+
services:
16+
- memcached
17+
- redis-server
18+
before_script:
19+
- |
20+
if [[ $TRAVIS_PHP_VERSION = "hhv"* ]]; then
21+
cat var/php/conf/phpfastcache.ini >> /etc/hhvm/php.ini
22+
else
23+
phpenv config-add var/php/conf/phpfastcache.ini
24+
fi
25+
26+
php:
27+
# - 5.3
28+
# - 5.4
29+
# - 5.5
30+
- 5.6
31+
- 7.0
32+
- nightly
33+
- hhvm
34+
35+
matrix:
36+
fast_finish: true
37+
allow_failures:
38+
- php: nightly
39+
- php: hhvm
40+
41+
install:
42+
- ./bin/ci/install_dependencies.sh
43+
44+
script:
45+
- php -f tests/SyntaxChecker.test.php

tests/SyntaxChecker.test.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
/**
4+
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
5+
* @author Georges.L (Geolim4) <contact@geolim4.com>
6+
*/
7+
function read_dir($dir, $ext = null)
8+
{
9+
$list = [];
10+
$dir .= '/';
11+
if (($res = opendir($dir)) === false) {
12+
exit(1);
13+
}
14+
while (($name = readdir($res)) !== false) {
15+
if ($name == '.' || $name == '..') {
16+
continue;
17+
}
18+
$name = $dir . $name;
19+
if (is_dir($name)) {
20+
$list = array_merge($list, read_dir($name, $ext));
21+
} elseif (is_file($name)) {
22+
if (!is_null($ext) && substr(strrchr($name, '.'), 1) != $ext) {
23+
continue;
24+
}
25+
$list[] = $name;
26+
}
27+
}
28+
29+
return $list;
30+
}
31+
32+
$list = read_dir(__DIR__ . '/../', 'php');
33+
$list += read_dir(__DIR__ . '/../', 'tpl');
34+
35+
$exit = 0;
36+
foreach ($list as $file) {
37+
$output = '';
38+
/**
39+
* @todo Make the exclusions much cleaner
40+
*/
41+
if (strpos($file, '/vendor/composer') === false && strpos($file, '/bin/stubs') === false) {
42+
exec('php -l "' . $file . '"', $output, $status);
43+
} else {
44+
echo '[SKIP] ' . $file;
45+
echo "\n";
46+
continue;
47+
}
48+
49+
if ($status !== 0) {
50+
$exit = $status;
51+
echo '[FAIL]';
52+
} else {
53+
echo '[PASS]';
54+
}
55+
echo ' ' . implode("\n", $output);
56+
echo "\n";
57+
}
58+
exit($exit);

var/php/conf/phpfastcache.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
; Adding required extensions for tests
2+
extension="memcached.so"
3+
extension="redis.so"

0 commit comments

Comments
 (0)