Running tests on a Nextcloud app

The sample Nextcloud app is generated with restrictions that won’t allow it to run on version 13 or above. This can be fixed by updating apps/foobar/appinfo/info.xml with:

<nextcloud min-version="12" max-version="14"/>

The Docker test container can be modified to run on /opt/nextcloud/server, a clone of the Nextcloud server including the generated app.

version: '3'

services:
  db:
    image: postgres
    restart: always
    volumes:
      - db:/var/lib/postgresql/data
    env_file:
      - db.env

  app:  
    image: nextcloud:fpm
    restart: always
    volumes:
      - /opt/nextcloud/server:/var/www/html
    environment:
      - POSTGRES_HOST=db
    env_file:
      - db.env
    depends_on:
      - db

  web:
    build: ./web
    restart: always
    ports:
      - 8080:80
    volumes:
      - /opt/nextcloud/server:/var/www/html:ro
    depends_on:
      - app

volumes:
  db:
#  nextcloud:

The phpunit-5.7 script is then installed with:

  • cd /usr/local/bin
  • wget -O phpunit https://phar.phpunit.de/phpunit-5.phar
  • chmod +x phpunit

and run with

  • cd /var/www/html
  • chown -R www-data .
  • cd apps/foobar
  • phpunit
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
.                                                                   1 / 1 (100%)
Time: 241 ms, Memory: 8.00MB
OK (1 test, 2 assertions)
  • phpunit –debug -c phpunit.integration.xml
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
Starting test 'OCA\FooBar\Tests\Integration\Controller\AppTest::testAppInstalled'.
.                                                                   1 / 1 (100%)
Time: 250 ms, Memory: 8.00MB
OK (1 test, 1 assertion)

Leave a Reply

Your email address will not be published. Required fields are marked *