mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 22:04:25 +02:00
Merge pull request #74 from Icinga/feature/travis
This commit is contained in:
commit
c554ebb473
10
.gitignore
vendored
10
.gitignore
vendored
@ -4,6 +4,16 @@
|
|||||||
# Except those related to git and vagrant
|
# Except those related to git and vagrant
|
||||||
!.git*
|
!.git*
|
||||||
!.puppet*
|
!.puppet*
|
||||||
|
!.travis.yml
|
||||||
|
!.mailmap
|
||||||
|
|
||||||
|
# Testing - created by test/setup_vendor.sh
|
||||||
|
/vendor/
|
||||||
|
/Hamcrest*
|
||||||
|
/Mockery*
|
||||||
|
/Icinga
|
||||||
|
/Zend
|
||||||
|
/*.phar
|
||||||
|
|
||||||
# Exclude application log files
|
# Exclude application log files
|
||||||
var/log/*
|
var/log/*
|
||||||
|
39
.travis.yml
Normal file
39
.travis.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
language: php
|
||||||
|
#dist: trusty
|
||||||
|
sudo: required
|
||||||
|
|
||||||
|
php:
|
||||||
|
- '5.3'
|
||||||
|
- '5.4'
|
||||||
|
- '5.5'
|
||||||
|
- '5.6'
|
||||||
|
- '7.0'
|
||||||
|
- '7.1'
|
||||||
|
|
||||||
|
services:
|
||||||
|
- mysql
|
||||||
|
- postgresql
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- vendor
|
||||||
|
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- /^v\d/
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
|
|
||||||
|
# also see: test/setup_vendor.sh
|
||||||
|
before_script:
|
||||||
|
- sudo locale-gen en_US.UTF-8 de_DE.UTF-8 fr_FR.UTF-8
|
||||||
|
- test/travis_database.sh
|
||||||
|
- test/setup_vendor.sh
|
||||||
|
|
||||||
|
script:
|
||||||
|
# also see: modules/test/application/clicommands/PhpCommand.php
|
||||||
|
# phpcs is disabled until fixed...
|
||||||
|
# - php phpcs.phar -p --standard=icingaweb2.ruleset.xml --extensions=php --encoding=utf-8 application/ library/Icinga modules/ test/
|
||||||
|
- php phpunit.phar -c modules/test/phpunit.xml --verbose
|
@ -1,5 +1,8 @@
|
|||||||
# Icinga Web 2
|
# Icinga Web 2
|
||||||
|
|
||||||
|
[](https://travis-ci.org/Icinga/icingaweb2)
|
||||||
|
[](https://github.com/Icinga/icingaweb2)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
1. [About](#about)
|
1. [About](#about)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!-- PHP Codesniffer ruleset configuration -->
|
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
|
<!-- PHP Codesniffer ruleset configuration -->
|
||||||
<ruleset name="icingaweb2">
|
<ruleset name="icingaweb2">
|
||||||
<description>The default PSR-2 standard with specifically excluded non-critical sniffs</description>
|
<description>The default PSR-2 standard with specifically excluded non-critical sniffs</description>
|
||||||
<!-- Include the whole PSR-2 standard -->
|
<!-- Include the whole PSR-2 standard -->
|
||||||
|
@ -43,7 +43,12 @@ class Json
|
|||||||
*/
|
*/
|
||||||
public static function decode($json, $assoc = false, $depth = 512, $options = 0)
|
public static function decode($json, $assoc = false, $depth = 512, $options = 0)
|
||||||
{
|
{
|
||||||
$decoded = json_decode($json, $assoc, $depth, $options);
|
if (version_compare(phpversion(), '5.4.0', '<')) {
|
||||||
|
$decoded = json_decode($json, $assoc, $depth);
|
||||||
|
} else {
|
||||||
|
$decoded = json_decode($json, $assoc, $depth, $options);
|
||||||
|
}
|
||||||
|
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
throw new JsonDecodeException('%s: %s', static::lastErrorMsg(), var_export($json, true));
|
throw new JsonDecodeException('%s: %s', static::lastErrorMsg(), var_export($json, true));
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
namespace Tests\Icinga\Modules\Monitoring\Web\Rest;
|
namespace Tests\Icinga\Modules\Monitoring\Web\Rest;
|
||||||
|
|
||||||
use Icinga\Exception\Json\JsonDecodeException;
|
|
||||||
use Icinga\Module\Monitoring\Web\Rest\RestRequest;
|
use Icinga\Module\Monitoring\Web\Rest\RestRequest;
|
||||||
use Icinga\Test\BaseTestCase;
|
use Icinga\Test\BaseTestCase;
|
||||||
|
|
||||||
@ -18,7 +17,7 @@ class MockedRestRequest extends RestRequest
|
|||||||
class RestRequestTest extends BaseTestCase
|
class RestRequestTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @expectedException JsonDecodeException
|
* @expectedException \Icinga\Exception\Json\JsonDecodeException
|
||||||
*/
|
*/
|
||||||
public function testInvalidServerResponseHandling()
|
public function testInvalidServerResponseHandling()
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,10 @@ $mockeryLoader->register();
|
|||||||
|
|
||||||
require_once($icingaLibPath . '/Test/ClassLoader.php');
|
require_once($icingaLibPath . '/Test/ClassLoader.php');
|
||||||
|
|
||||||
|
if (! class_exists('PHPUnit_Framework_TestCase')) {
|
||||||
|
require_once __DIR__ . '/phpunit-compat.php';
|
||||||
|
}
|
||||||
|
|
||||||
$loader = new Icinga\Test\ClassLoader();
|
$loader = new Icinga\Test\ClassLoader();
|
||||||
$loader->registerNamespace('Tests', $testLibraryPath);
|
$loader->registerNamespace('Tests', $testLibraryPath);
|
||||||
$loader->registerNamespace('Icinga', $icingaLibPath);
|
$loader->registerNamespace('Icinga', $icingaLibPath);
|
||||||
|
15
test/php/phpunit-compat.php
Normal file
15
test/php/phpunit-compat.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @codingStandardsIgnoreStart
|
||||||
|
*/
|
||||||
|
class PHPUnit_Framework_TestCase extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PHPUnit_Framework_Test extends \PHPUnit\Framework\Test
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PHPUnit_Framework_TestListener extends \PHPUnit\Framework\TestListener
|
||||||
|
{
|
||||||
|
}
|
58
test/setup_vendor.sh
Executable file
58
test/setup_vendor.sh
Executable file
@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
ICINGAWEB_HOME=${ICINGAWEB_HOME:="$(dirname "$(readlink -f $(dirname "$0"))")"}
|
||||||
|
PHP_VERSION="$(php -r 'echo phpversion();')"
|
||||||
|
PHPCS_VERSION=${PHPCS_VERSION:=2.9.1}
|
||||||
|
MOCKERY_VERSION=${MOCKERY_VERSION:=0.9.9}
|
||||||
|
HAMCREST_VERSION=${HAMCREST_VERSION:=2.0.0}
|
||||||
|
|
||||||
|
if [ "$PHP_VERSION" '<' 5.6.0 ]; then
|
||||||
|
PHPUNIT_VERSION=${PHPUNIT_VERSION:=4.8}
|
||||||
|
else
|
||||||
|
PHPUNIT_VERSION=${PHPUNIT_VERSION:=5.7}
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ${ICINGAWEB_HOME}
|
||||||
|
|
||||||
|
test -d vendor || mkdir vendor
|
||||||
|
|
||||||
|
# phpunit
|
||||||
|
phpunit_path="vendor/phpunit-${PHPUNIT_VERSION}"
|
||||||
|
if [ ! -e "${phpunit_path}".phar ]; then
|
||||||
|
wget -O "${phpunit_path}".phar https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar
|
||||||
|
fi
|
||||||
|
ln -svf "${phpunit_path}".phar phpunit.phar
|
||||||
|
|
||||||
|
# phpcs
|
||||||
|
phpcs_path="vendor/phpcs-${PHPCS_VERSION}"
|
||||||
|
if [ ! -e "${phpcs_path}".phar ]; then
|
||||||
|
wget -O "${phpcs_path}".phar \
|
||||||
|
https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${PHPCS_VERSION}/phpcs.phar
|
||||||
|
fi
|
||||||
|
ln -svf "${phpcs_path}".phar phpcs.phar
|
||||||
|
|
||||||
|
# mockery
|
||||||
|
mockery_path="vendor/mockery-${MOCKERY_VERSION}"
|
||||||
|
if [ ! -e "${mockery_path}".tar.gz ]; then
|
||||||
|
wget -O "${mockery_path}".tar.gz \
|
||||||
|
https://github.com/mockery/mockery/archive/${MOCKERY_VERSION}.tar.gz
|
||||||
|
fi
|
||||||
|
if [ ! -d "${mockery_path}" ]; then
|
||||||
|
tar xf "${mockery_path}".tar.gz -C vendor/
|
||||||
|
fi
|
||||||
|
ln -svf "${mockery_path}"/library/Mockery
|
||||||
|
ln -svf "${mockery_path}"/library/Mockery.php
|
||||||
|
|
||||||
|
# hamcrest
|
||||||
|
hamcrest_path="vendor/hamcrest-php-${HAMCREST_VERSION}"
|
||||||
|
if [ ! -e "${hamcrest_path}".tar.gz ]; then
|
||||||
|
wget -O "${hamcrest_path}".tar.gz \
|
||||||
|
https://github.com/hamcrest/hamcrest-php/archive/v${HAMCREST_VERSION}.tar.gz
|
||||||
|
fi
|
||||||
|
if [ ! -d "${hamcrest_path}" ]; then
|
||||||
|
tar xf "${hamcrest_path}".tar.gz -C vendor/
|
||||||
|
fi
|
||||||
|
ln -svf "${hamcrest_path}"/hamcrest/Hamcrest
|
||||||
|
ln -svf "${hamcrest_path}"/hamcrest/Hamcrest.php
|
11
test/travis_database.sh
Executable file
11
test/travis_database.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
mysql -u root -e "GRANT ALL ON *.* TO icinga_unittest@localhost IDENTIFIED BY 'icinga_unittest'"
|
||||||
|
|
||||||
|
export PGHOST=localhost
|
||||||
|
export PGUSER=postgres
|
||||||
|
|
||||||
|
psql -c "CREATE USER icinga_unittest WITH PASSWORD 'icinga_unittest'"
|
||||||
|
psql -c "CREATE DATABASE icinga_unittest WITH OWNER icinga_unittest"
|
Loading…
x
Reference in New Issue
Block a user