diff --git a/.gitignore b/.gitignore index e69de29..7579f74 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor +composer.lock diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..3ac245a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,36 @@ +language: php +sudo: false + +jobs: + include: + - stage: Unit tests + env: + php: 7.0 + - env: COMPOSER_FLAGS="--prefer-lowest" + php: 7.0 + - env: + php: 7.1 + - env: COMPOSER_FLAGS="--prefer-lowest" + php: 7.1 + - env: + php: 7.2 + - env: COMPOSER_FLAGS="--prefer-lowest" + php: 7.2 + - env: + php: 7.3 + - env: COMPOSER_FLAGS="--prefer-lowest" + php: 7.3 + +before_install: +- composer self-update + +install: +- composer update -o $COMPOSER_FLAGS + +script: +- ./vendor/bin/phpunit + +cache: + directories: + - vendor + - $HOME/.composer/cache diff --git a/composer.json b/composer.json index e02d8af..6a1b3fa 100644 --- a/composer.json +++ b/composer.json @@ -13,15 +13,22 @@ } ], "require": { - "php": "^5.6 || ^7.0", - "sentry/sentry": "^1.9.2" + "php": ">=7.0", + "sentry/sentry": "^1.9.2", + "zendframework/zend-eventmanager": "^2.5|| ^3.0", + "zendframework/zend-mvc": "^2.5 || ^3.0", + "zendframework/zend-log": "^2.5 || ^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.5" }, "conflict": { "zendframework/zendframework": "<3.0.0" }, "autoload": { "psr-0": { - "ZendSentry": "src/" + "ZendSentry": "src/", + "ZendSentryTests": "tests/" }, "classmap": [ "./Module.php" diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..31a9fc0 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,26 @@ + + + ./tests/ZendSentryTest + + + + + + ./src + ./../Module.php + + + + + + + + diff --git a/tests/ZendSentryTest/ModuleTest.php b/tests/ZendSentryTest/ModuleTest.php new file mode 100644 index 0000000..efe756d --- /dev/null +++ b/tests/ZendSentryTest/ModuleTest.php @@ -0,0 +1,45 @@ +module = new ZendSentryModule(); + } + + public function testDefaultModuleConfig() + { + $expectedConfig = []; + + $actualConfig = $this->module->getConfig(); + + $this->assertEquals($expectedConfig, $actualConfig); + } + + public function testAutoloaderConfig() + { + $expectedConfig = [ + StandardAutoloader::class => [ + 'namespaces' => [ + 'ZendSentry' => realpath(__DIR__. '/../../src/ZendSentry') + ] + ] + ]; + + $actualConfig = $this->module->getAutoloaderConfig(); + + $this->assertEquals($expectedConfig, $actualConfig); + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..393ff00 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,18 @@ +add('ZendSentryTest', __DIR__); + +if (!$config = @include 'configuration.php') { + $config = require 'configuration.php.dist'; +} diff --git a/tests/configuration.php.dist b/tests/configuration.php.dist new file mode 100644 index 0000000..d266508 --- /dev/null +++ b/tests/configuration.php.dist @@ -0,0 +1,2 @@ +