Require local phpunit through composer and bump phpunit version

* Uses PHPUnit 6.5 (requires PHP 7.0+, but we got rid with NC 14 (see nextcloud/server#7368)
* Namespaces are rewritten
* If composer isn't installed, it installs it (taken from nextcloud/news)

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Remove PHPUnit Download in CI

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Properly handle phpunit on travis for 5.6

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Remove trouble composer.lock

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Don't install composer deps twice on CI

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2018-08-06 15:12:59 +02:00
parent ed519db3d5
commit 599c8ac6a1
10 changed files with 45 additions and 19 deletions

View File

@ -88,7 +88,7 @@ before_script:
script:
- make
- phpunit --version
- make composer || true
- make test
- make dist
# Upload nightly

View File

@ -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

5
composer.json Normal file
View File

@ -0,0 +1,5 @@
{
"require-dev": {
"phpunit/phpunit": "^6.5"
}
}

View File

@ -23,7 +23,7 @@ if (version_compare(implode('.', \OCP\Util::getVersion()), '8.2', '>=')) {
\OC_App::loadApp('calendar');
}
if(!class_exists('PHPUnit_Framework_TestCase')) {
if(!class_exists('PHPUnit\Framework\TestCase')) {
require_once('PHPUnit/Autoload.php');
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 @@ class StreamResponseTest extends \PHPUnit_Framework_TestCase {
$streamResponse = new StreamResponse($stream);
$streamResponse->callback($ioutput);
}
}
}