From 68dc3e56bc2694b552d4de23c1b9146fee894fa7 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 13 Nov 2023 20:58:01 +0100 Subject: [PATCH] use standard workflows --- .github/workflows/dokuwiki.yml | 11 ++++ .github/workflows/phpTestLinux.yml | 52 ------------------ _test/GeneralTest.php | 86 ++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/dokuwiki.yml delete mode 100644 .github/workflows/phpTestLinux.yml create mode 100644 _test/GeneralTest.php diff --git a/.github/workflows/dokuwiki.yml b/.github/workflows/dokuwiki.yml new file mode 100644 index 0000000..0b4a469 --- /dev/null +++ b/.github/workflows/dokuwiki.yml @@ -0,0 +1,11 @@ +name: DokuWiki Default Tasks +on: + push: + pull_request: + schedule: + - cron: '33 0 15 * *' + + +jobs: + all: + uses: dokuwiki/github-action/.github/workflows/all.yml@main diff --git a/.github/workflows/phpTestLinux.yml b/.github/workflows/phpTestLinux.yml deleted file mode 100644 index 23a9fbc..0000000 --- a/.github/workflows/phpTestLinux.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: PHP Tests on Linux - -on: [push, pull_request] - -jobs: - testLinux: - name: PHP ${{ matrix.php-versions }} DokuWiki ${{ matrix.dokuwiki-branch }} - runs-on: ubuntu-latest - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository - - strategy: - matrix: - php-versions: ['7.2', '7.3', '7.4', '8.0'] - dokuwiki-branch: [ 'master', 'stable'] - exclude: - - dokuwiki-branch: 'stable' - php-versions: '8.0' - fail-fast: false - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - extensions: mbstring, intl, PDO, pdo_sqlite, bz2 - - - name: Setup problem matchers - run: | - echo ::add-matcher::${{ runner.tool_cache }}/php.json - echo ::add-matcher::${{ runner.tool_cache }}/phpunit.json - - - name: Download DokuWiki Test-setup - run: wget https://raw.github.com/splitbrain/dokuwiki-travis/master/travis.sh - - - name: Run DokuWiki Test-setup - env: - CI_SERVER: 1 - DOKUWIKI: ${{ matrix.dokuwiki-branch }} - run: sh travis.sh - - - name: Setup PHPUnit - run: | - php _test/fetchphpunit.php - cd _test - - - name: Run PHPUnit - run: | - cd _test - php phpunit.phar --verbose --stderr --group plugin_dev diff --git a/_test/GeneralTest.php b/_test/GeneralTest.php new file mode 100644 index 0000000..6909c82 --- /dev/null +++ b/_test/GeneralTest.php @@ -0,0 +1,86 @@ +assertFileExists($file); + + $info = confToHash($file); + + $this->assertArrayHasKey('base', $info); + $this->assertArrayHasKey('author', $info); + $this->assertArrayHasKey('email', $info); + $this->assertArrayHasKey('date', $info); + $this->assertArrayHasKey('name', $info); + $this->assertArrayHasKey('desc', $info); + $this->assertArrayHasKey('url', $info); + + $this->assertEquals('dev', $info['base']); + $this->assertRegExp('/^https?:\/\//', $info['url']); + $this->assertTrue(mail_isvalid($info['email'])); + $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); + $this->assertTrue(false !== strtotime($info['date'])); + } + + /** + * Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in + * conf/metadata.php. + */ + public function testPluginConf(): void + { + $conf_file = __DIR__ . '/../conf/default.php'; + $meta_file = __DIR__ . '/../conf/metadata.php'; + + if (!file_exists($conf_file) && !file_exists($meta_file)) { + self::markTestSkipped('No config files exist -> skipping test'); + } + + if (file_exists($conf_file)) { + include($conf_file); + } + if (file_exists($meta_file)) { + include($meta_file); + } + + $this->assertEquals( + gettype($conf), + gettype($meta), + 'Both ' . DOKU_PLUGIN . 'dev/conf/default.php and ' . DOKU_PLUGIN . 'dev/conf/metadata.php have to exist and contain the same keys.' + ); + + if ($conf !== null && $meta !== null) { + foreach ($conf as $key => $value) { + $this->assertArrayHasKey( + $key, + $meta, + 'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'dev/conf/metadata.php' + ); + } + + foreach ($meta as $key => $value) { + $this->assertArrayHasKey( + $key, + $conf, + 'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'dev/conf/default.php' + ); + } + } + + } +}