diff --git a/.travis.yml b/.travis.yml index bfa722b7a0..a1501c2c33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -88,7 +88,7 @@ before_script: script: - make - - phpunit --version + - make composer || true - make test - make dist # Upload nightly diff --git a/Makefile b/Makefile index 273b8d1fd3..056610b079 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,10 @@ appstore_artifact_directory=$(CURDIR)/build/artifacts/appstore appstore_package_name=$(appstore_artifact_directory)/$(app_name) yarn=$(shell which yarn 2> /dev/null) gcp=$(shell which gcp 2> /dev/null) +composer:=$(shell which composer 2> /dev/null) +ifeq (,$(composer)) + composer:=php $(build_tools_directory)/composer.phar +endif ifeq (, $(gcp)) copy_command=cp @@ -85,6 +89,18 @@ all: build build: make yarn +# Installs and updates the composer dependencies. If composer is not installed +# a copy is fetched from the web +.PHONY: composer +composer: +ifeq (, $(shell which composer 2> /dev/null)) + @echo "No composer command available, downloading a copy from the web" + mkdir -p $(build_tools_directory) + curl -sS https://getcomposer.org/installer | php + mv composer.phar $(build_tools_directory) +endif + $(composer) install --prefer-dist + # Installs yarn dependencies .PHONY: yarn yarn: @@ -159,14 +175,8 @@ endif # from the internet .PHONY: test test: - cd js && $(yarn) run test -ifeq (, $(shell which phpunit 2> /dev/null)) - @echo "No phpunit command available, downloading a copy from the web" - mkdir -p $(build_tools_directory) - curl -sSL https://phar.phpunit.de/phpunit.phar -o $(build_tools_directory)/phpunit.phar - php $(build_tools_directory)/phpunit.phar -c phpunit.xml --coverage-clover coverage.clover - # php $(build_tools_directory)/phpunit.phar -c phpunit.integration.xml --coverage-clover build/php-integration.clover -else - phpunit -c phpunit.xml --coverage-clover coverage.clover --bootstrap - # phpunit -c phpunit.integration.xml --coverage-clover build/php-unit.clover +ifndef TRAVIS + make composer endif + cd js && $(yarn) run test && cd ../ + export PATH="$$PWD/vendor/bin:$$PATH" && phpunit -c phpunit.xml --coverage-clover coverage.clover diff --git a/composer.json b/composer.json new file mode 100644 index 0000000000..0bfa069f93 --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require-dev": { + "phpunit/phpunit": "^6.5" + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index b0be2506df..b8463fd05b 100755 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -23,7 +23,7 @@ \OC_App::loadApp('calendar'); } -if(!class_exists('PHPUnit_Framework_TestCase')) { +if(!class_exists('PHPUnit\Framework\TestCase')) { require_once('PHPUnit/Autoload.php'); } diff --git a/tests/php/controller/contactcontrollerTest.php b/tests/php/controller/contactcontrollerTest.php index e2b491e88a..6f8b0d9ddd 100644 --- a/tests/php/controller/contactcontrollerTest.php +++ b/tests/php/controller/contactcontrollerTest.php @@ -21,7 +21,9 @@ */ namespace OCA\Calendar\Controller; -class ContactControllerTest extends \PHPUnit_Framework_TestCase { +use PHPUnit\Framework\TestCase; + +class ContactControllerTest extends TestCase { private $appName; private $request; diff --git a/tests/php/controller/emailcontrollerTest.php b/tests/php/controller/emailcontrollerTest.php index 5a917c97ed..d6c3ee37e8 100644 --- a/tests/php/controller/emailcontrollerTest.php +++ b/tests/php/controller/emailcontrollerTest.php @@ -21,7 +21,9 @@ */ namespace OCA\Calendar\Controller; -class EmailControllerTest extends \PHPUnit_Framework_TestCase { +use PHPUnit\Framework\TestCase; + +class EmailControllerTest extends TestCase { private $appName; private $request; diff --git a/tests/php/controller/proxycontrollerTest.php b/tests/php/controller/proxycontrollerTest.php index 872aa52f63..03b2fef9ac 100644 --- a/tests/php/controller/proxycontrollerTest.php +++ b/tests/php/controller/proxycontrollerTest.php @@ -21,11 +21,12 @@ */ namespace OCA\Calendar\Controller; +use PHPUnit\Framework\TestCase; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Exception\ConnectException; -class ProxyControllerTest extends \PHPUnit_Framework_TestCase { +class ProxyControllerTest extends TestCase { private $appName; private $request; diff --git a/tests/php/controller/settingscontrollerTest.php b/tests/php/controller/settingscontrollerTest.php index 0f8b3566d3..fecbd34f7e 100755 --- a/tests/php/controller/settingscontrollerTest.php +++ b/tests/php/controller/settingscontrollerTest.php @@ -21,7 +21,9 @@ */ namespace OCA\Calendar\Controller; -class SettingsControllerTest extends \PHPUnit_Framework_TestCase { +use PHPUnit\Framework\TestCase; + +class SettingsControllerTest extends TestCase { private $appName; private $request; diff --git a/tests/php/controller/viewcontrollerTest.php b/tests/php/controller/viewcontrollerTest.php index 62645a3f50..0baed8e4df 100755 --- a/tests/php/controller/viewcontrollerTest.php +++ b/tests/php/controller/viewcontrollerTest.php @@ -22,7 +22,9 @@ namespace OCA\Calendar\Controller; -class ViewControllerTest extends \PHPUnit_Framework_TestCase { +use PHPUnit\Framework\TestCase; + +class ViewControllerTest extends TestCase { private $appName; private $request; diff --git a/tests/php/http/streamresponseTest.php b/tests/php/http/streamresponseTest.php index fa56c4e48d..f731b67da1 100644 --- a/tests/php/http/streamresponseTest.php +++ b/tests/php/http/streamresponseTest.php @@ -21,7 +21,9 @@ */ namespace OCA\Calendar\Http; -class StreamResponseTest extends \PHPUnit_Framework_TestCase { +use PHPUnit\Framework\TestCase; + +class StreamResponseTest extends TestCase { public function setUp() { @@ -38,4 +40,4 @@ public function testCallback() { $streamResponse = new StreamResponse($stream); $streamResponse->callback($ioutput); } -} \ No newline at end of file +}