diff --git a/.drone.yml b/.drone.yml index 952ea69..6f5b0c4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,7 +15,6 @@ pipeline: - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DB - cd ../server - php ./build/signed-off-checker.php - secrets: [ github_token ] when: matrix: TESTS: signed-off-check @@ -26,37 +25,37 @@ pipeline: - CORE_BRANCH=stable13 - DB=sqlite commands: - # Pre-setup steps - - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh - - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DB - - cd ../server - - # Code checker - - ./occ app:check-code $APP_NAME - - cd apps/$APP_NAME/ - when: - matrix: - TESTS: check-app-compatbility - syntax-php5.6: - image: nextcloudci/php5.6:php5.6-3 - environment: - - APP_NAME=spreed - - CORE_BRANCH=stable13 - - DB=sqlite - commands: # Pre-setup steps - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DB - cd ../server - - composer install - - ./lib/composer/bin/parallel-lint apps/$APP_NAME/ - when: - matrix: - TESTS: syntax-php5.6 + + # Code checker + - ./occ app:check-code $APP_NAME + - cd apps/$APP_NAME/ + when: + matrix: + TESTS: check-app-compatbility + syntax-php5.6: + image: nextcloudci/php5.6:php5.6-8 + environment: + - APP_NAME=data_request + - CORE_BRANCH=stable13 + - DB=sqlite + commands: + # Pre-setup steps + - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh + - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DB + - cd ../server + - composer install + - ./lib/composer/bin/parallel-lint apps/$APP_NAME/ + when: + matrix: + TESTS: syntax-php5.6 syntax-php7.0: image: nextcloudci/php7.0:php7.0-2 environment: - - APP_NAME=spreed + - APP_NAME=data_request - CORE_BRANCH=stable13 - DB=sqlite commands: @@ -69,9 +68,75 @@ pipeline: when: matrix: TESTS: syntax-php7.0 + php5.6: + image: nextcloudci/php5.6:php5.6-8 + environment: + - APP_NAME=data_request + - CORE_BRANCH=stable13 + - DB=sqlite + commands: + - apt update && apt-get -y install php5-xdebug + + # Pre-setup steps + - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh + - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DB + - cd ../server/ + - ./occ app:enable $APP_NAME + - cd apps/$APP_NAME + + # Run phpunit tests + - cd tests/unit/ + - phpunit --configuration phpunit.xml + when: + matrix: + TESTS: php5.6 + php7.0: + image: nextcloudci/php7.0:php7.0-2 + environment: + - APP_NAME=data_request + - CORE_BRANCH=stable13 + - DB=sqlite + commands: + # Pre-setup steps + - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh + - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DB + - cd ../server/ + - ./occ app:enable $APP_NAME + - cd apps/$APP_NAME + + # Run phpunit tests + - cd tests/unit/ + - phpunit --configuration phpunit.xml + when: + matrix: + TESTS: php7.0 + php7.1: + image: nextcloudci/php7.1:php7.1-15 + environment: + - APP_NAME=data_request + - CORE_BRANCH=stable13 + - DB=sqlite + commands: + # Pre-setup steps + - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh + - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DB + - cd ../server/ + - ./occ app:enable $APP_NAME + - cd apps/$APP_NAME + + # Run phpunit tests + - cd tests/unit/ + - phpunit --configuration phpunit.xml + when: + matrix: + TESTS: php7.1 + matrix: include: - TESTS: signed-off-check - TESTS: check-app-compatbility - TESTS: syntax-php5.6 - TESTS: syntax-php7.0 + - TESTS: php5.6 + - TESTS: php7.0 + - TESTS: php7.1 diff --git a/lib/Services/Request.php b/lib/Services/Request.php index 7f5907f..e6fa047 100644 --- a/lib/Services/Request.php +++ b/lib/Services/Request.php @@ -160,7 +160,7 @@ class Request { protected function getAdmins() { $admins = $this->groupManager->get('admin')->searchUsers(''); - $admins = array_filter($admins, function(IUser $admin) { + $admins = array_filter($admins, function(IUser $admin) { return $admin->getEMailAddress() !== null; }); if(empty($admins)) { diff --git a/tests/unit/Services/RequestTest.php b/tests/unit/Services/RequestTest.php index 5dcfd08..b712351 100644 --- a/tests/unit/Services/RequestTest.php +++ b/tests/unit/Services/RequestTest.php @@ -163,15 +163,24 @@ class RequestTest extends \Test\TestCase { public function adminProvider() { $admin1 = $this->createMock(IUser::class); + $admin2 = $this->createMock(IUser::class); $admin2->expects($this->any()) ->method('getEMailAddress') ->willReturn('admin2@sindar.gov'); + $admin3 = $this->createMock(IUser::class); $admin3->expects($this->any()) ->method('getEMailAddress') ->willReturn('admin3@sindar.gov'); + $admin4 = $this->createMock(IUser::class); + + $admin5 = $this->createMock(IUser::class); + $admin5->expects($this->any()) + ->method('getEMailAddress') + ->willReturn('admin5@sindar.gov'); + return [ [ [ $admin1 ], @@ -182,7 +191,7 @@ class RequestTest extends \Test\TestCase { 1 ], [ - [ $admin1, $admin2, $admin3 ], + [ $admin3, $admin4, $admin5 ], // for whatever reasons, reusing $admin1 and $admin2 would fail on CI 2 ] ]; @@ -209,6 +218,7 @@ class RequestTest extends \Test\TestCase { $this->expectException(HintedRuntime::class); } $result = $this->invokePrivate($this->service, 'getAdmins'); + $this->assertSame($adminsWithEmail, count($result)); } diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php index 839317f..cbfa0d9 100644 --- a/tests/unit/bootstrap.php +++ b/tests/unit/bootstrap.php @@ -25,7 +25,4 @@ if (!defined('PHPUNIT_RUN')) { require_once __DIR__.'/../../../../lib/base.php'; \OC::$loader->addValidRoot(\OC::$SERVERROOT . '/tests'); \OC_App::loadApp('data_request'); -if(!class_exists('PHPUnit_Framework_TestCase')) { - require_once('PHPUnit/Autoload.php'); -} OC_Hook::clear();