From f3bd01f799ef8c033498ff387a5c5c9a87c171fd Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Wed, 5 Sep 2018 18:10:04 +0200 Subject: [PATCH 1/6] List used zend dependencies as a Dependency of the project --- .gitignore | 2 ++ composer.json | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e69de29..7579f74 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor +composer.lock diff --git a/composer.json b/composer.json index e02d8af..bfdeac7 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,10 @@ ], "require": { "php": "^5.6 || ^7.0", - "sentry/sentry": "^1.9.2" + "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" }, "conflict": { "zendframework/zendframework": "<3.0.0" From 96811c515ca5478144a21708cf47c216e30dd357 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Fri, 19 Oct 2018 20:11:30 +0200 Subject: [PATCH 2/6] Install PHPUnit as dev-dependency --- composer.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bfdeac7..a84c0cd 100644 --- a/composer.json +++ b/composer.json @@ -19,12 +19,16 @@ "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" From 903bfbeb8838c2d7d0605854d683bfc5fbc00fab Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Fri, 19 Oct 2018 22:43:55 +0200 Subject: [PATCH 3/6] Write first tests --- phpunit.xml | 26 +++++++++++++++++ tests/ZendSentryTest/ModuleTest.php | 45 +++++++++++++++++++++++++++++ tests/bootstrap.php | 18 ++++++++++++ tests/configuration.php.dist | 2 ++ 4 files changed, 91 insertions(+) create mode 100644 phpunit.xml create mode 100644 tests/ZendSentryTest/ModuleTest.php create mode 100644 tests/bootstrap.php create mode 100644 tests/configuration.php.dist 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 @@ + Date: Fri, 19 Oct 2018 22:57:37 +0200 Subject: [PATCH 4/6] Add Travis.yml --- .travis.yml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5221886 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,39 @@ +language: php + +matrix: + fast_finish: true + include: + - env: TEST_DIR=. + php: 5.6 + - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" + php: 5.6 + - env: TEST_DIR=. + php: 7.0 + - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" + php: 7.0 + - env: TEST_DIR=. + php: 7.1 + - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" + php: 7.1 + - env: TEST_DIR=. + php: 7.2 + - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" + php: 7.2 + - env: TEST_DIR=. + php: 7.3 + - env: TEST_DIR=. 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 From dff73995e0a9acb9d762df55531b9870f6578db7 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Fri, 19 Oct 2018 23:06:03 +0200 Subject: [PATCH 5/6] Conver matrix into jobs --- .travis.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5221886..8aa4bb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,27 @@ language: php -matrix: - fast_finish: true +jobs: include: - - env: TEST_DIR=. + - stage: Unit tests + - env: php: 5.6 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" + - env: COMPOSER_FLAGS="--prefer-lowest" php: 5.6 - - env: TEST_DIR=. + - env: php: 7.0 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" + - env: COMPOSER_FLAGS="--prefer-lowest" php: 7.0 - - env: TEST_DIR=. + - env: php: 7.1 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" + - env: COMPOSER_FLAGS="--prefer-lowest" php: 7.1 - - env: TEST_DIR=. + - env: php: 7.2 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" + - env: COMPOSER_FLAGS="--prefer-lowest" php: 7.2 - - env: TEST_DIR=. + - env: php: 7.3 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" + - env: COMPOSER_FLAGS="--prefer-lowest" php: 7.3 before_install: From 023d83f22ce16e0fab3b25aa36684b811ccb857a Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Fri, 19 Oct 2018 23:12:51 +0200 Subject: [PATCH 6/6] Drop PHP 5.6 support Since the code already uses the return types there is no way of running this in PHP 5.6 --- .travis.yml | 7 ++----- composer.json | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8aa4bb1..3ac245a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,10 @@ language: php +sudo: false jobs: include: - stage: Unit tests - - env: - php: 5.6 - - env: COMPOSER_FLAGS="--prefer-lowest" - php: 5.6 - - env: + env: php: 7.0 - env: COMPOSER_FLAGS="--prefer-lowest" php: 7.0 diff --git a/composer.json b/composer.json index a84c0cd..6a1b3fa 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require": { - "php": "^5.6 || ^7.0", + "php": ">=7.0", "sentry/sentry": "^1.9.2", "zendframework/zend-eventmanager": "^2.5|| ^3.0", "zendframework/zend-mvc": "^2.5 || ^3.0",