Skip to content

Commit

Permalink
Require local phpunit through composer and bump phpunit version
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
tcitworld committed Aug 6, 2018
1 parent ed519db commit 599c8ac
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ before_script:

script:
- make
- phpunit --version
- make composer || true
- make test
- make dist
# Upload nightly
Expand Down
30 changes: 20 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require-dev": {
"phpunit/phpunit": "^6.5"
}
}
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
4 changes: 3 additions & 1 deletion tests/php/controller/contactcontrollerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion tests/php/controller/emailcontrollerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion tests/php/controller/proxycontrollerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion tests/php/controller/settingscontrollerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion tests/php/controller/viewcontrollerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions tests/php/http/streamresponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -38,4 +40,4 @@ public function testCallback() {
$streamResponse = new StreamResponse($stream);
$streamResponse->callback($ioutput);
}
}
}

0 comments on commit 599c8ac

Please sign in to comment.