diff --git a/.gitignore b/.gitignore index b2ba5381d..5c654a7ba 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,16 @@ # Except those related to git and vagrant !.git* !.puppet* +!.travis.yml +!.mailmap + +# Testing - created by test/setup_vendor.sh +/vendor/ +/Hamcrest* +/Mockery* +/Icinga +/Zend +/*.phar # Exclude application log files var/log/* diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..957e89cb3 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/README.md b/README.md index 2a7eeda69..25e812ede 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Icinga Web 2 +[![Build Status](https://travis-ci.org/Icinga/icingaweb2.png?branch=master)](https://travis-ci.org/Icinga/icingaweb2) +[![Github Tag](https://img.shields.io/github/tag/Icinga/icingaweb2.svg)](https://github.com/Icinga/icingaweb2) + ![Icinga Logo](https://www.icinga.com/wp-content/uploads/2014/06/icinga_logo.png) 1. [About](#about) diff --git a/icingaweb2.ruleset.xml b/icingaweb2.ruleset.xml index edbcec706..020f26c26 100644 --- a/icingaweb2.ruleset.xml +++ b/icingaweb2.ruleset.xml @@ -1,5 +1,5 @@ - + The default PSR-2 standard with specifically excluded non-critical sniffs diff --git a/library/Icinga/Util/Json.php b/library/Icinga/Util/Json.php index c2c1f7a6d..3bd988bc0 100644 --- a/library/Icinga/Util/Json.php +++ b/library/Icinga/Util/Json.php @@ -43,7 +43,12 @@ class Json */ 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) { throw new JsonDecodeException('%s: %s', static::lastErrorMsg(), var_export($json, true)); } diff --git a/modules/monitoring/test/php/library/Monitoring/Web/Rest/RestRequestTest.php b/modules/monitoring/test/php/library/Monitoring/Web/Rest/RestRequestTest.php index 432ff8a26..e422ec076 100644 --- a/modules/monitoring/test/php/library/Monitoring/Web/Rest/RestRequestTest.php +++ b/modules/monitoring/test/php/library/Monitoring/Web/Rest/RestRequestTest.php @@ -3,7 +3,6 @@ namespace Tests\Icinga\Modules\Monitoring\Web\Rest; -use Icinga\Exception\Json\JsonDecodeException; use Icinga\Module\Monitoring\Web\Rest\RestRequest; use Icinga\Test\BaseTestCase; @@ -18,7 +17,7 @@ class MockedRestRequest extends RestRequest class RestRequestTest extends BaseTestCase { /** - * @expectedException JsonDecodeException + * @expectedException \Icinga\Exception\Json\JsonDecodeException */ public function testInvalidServerResponseHandling() { diff --git a/test/php/bootstrap.php b/test/php/bootstrap.php index 580013fd2..2c805e8b5 100644 --- a/test/php/bootstrap.php +++ b/test/php/bootstrap.php @@ -26,6 +26,10 @@ $mockeryLoader->register(); require_once($icingaLibPath . '/Test/ClassLoader.php'); +if (! class_exists('PHPUnit_Framework_TestCase')) { + require_once __DIR__ . '/phpunit-compat.php'; +} + $loader = new Icinga\Test\ClassLoader(); $loader->registerNamespace('Tests', $testLibraryPath); $loader->registerNamespace('Icinga', $icingaLibPath); diff --git a/test/php/phpunit-compat.php b/test/php/phpunit-compat.php new file mode 100644 index 000000000..88287906d --- /dev/null +++ b/test/php/phpunit-compat.php @@ -0,0 +1,15 @@ +