Skip to content

Commit

Permalink
Merge branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Cube707 committed Jan 4, 2024
2 parents 1eea003 + 6be89d3 commit 6300548
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fixes:
- "/phpBB3/phpBB/ext/cube/matomoanalytics/::"
85 changes: 67 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ on:
jobs:
# START Basic Checks Job (EPV, code sniffer, images check, etc.)
basic-checks:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- php: '7.1'
- php: '7.2'
db: "none"
NOTESTS: 1

name: PHP ${{ matrix.php }} - ${{ matrix.db }}

steps:
- name: Checkout phpBB
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: phpbb/phpbb
ref: ${{ env.PHPBB_BRANCH }}
path: phpBB3

- name: Checkout extension
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}

Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:

# START MySQL and MariaDB Job
mysql-tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
matrix:
include:
Expand All @@ -113,6 +113,8 @@ jobs:
db: "mysql:5.7"
- php: '7.2'
db: "mysql:5.7"
COVERAGE: 1
db_alias: "mysql:5.7 with Coverage"
- php: '7.3'
db: "mysql:5.7"
- php: '7.4'
Expand All @@ -123,6 +125,8 @@ jobs:
db: "mysql:5.7"
- php: '8.1'
db: "mysql:5.7"
- php: '8.2'
db: "mysql:5.7"

name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}

Expand Down Expand Up @@ -152,14 +156,14 @@ jobs:

steps:
- name: Checkout phpBB
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: phpbb/phpbb
ref: ${{ env.PHPBB_BRANCH }}
path: phpBB3

- name: Checkout extension
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}

Expand All @@ -168,15 +172,24 @@ jobs:
MATRIX_DB: ${{ matrix.db }}
run: |
db=$(echo "${MATRIX_DB%%:*}")
echo "::set-output name=db::$db"
echo "db=$db" >> $GITHUB_OUTPUT
- name: Setup PHP
if: ${{ matrix.COVERAGE != 1 }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap
coverage: none

- name: Setup PHP with Coverage
if: ${{ matrix.COVERAGE == 1 }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap
coverage: xdebug

- name: Setup environment for phpBB
env:
DB: ${{steps.database-type.outputs.db}}
Expand All @@ -193,19 +206,41 @@ jobs:
working-directory: ./phpBB3

- name: Setup PHPUnit files
run: mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_
env:
DB: ${{steps.database-type.outputs.db}}
COVERAGE: ${{ matrix.COVERAGE != 1 && '0' || '1' }}
run: |
if [ $COVERAGE == '1' ]
then
sed -n '1h;1!H;${;g;s/<\/php>/<\/php>\n\t<filter>\n\t\t<whitelist>\n\t\t\t<directory>..\/<\/directory>\n\t\t\t<exclude>\n\t\t\t\t<directory>..\/tests\/<\/directory>\n\t\t\t\t<directory>..\/language\/<\/directory>\n\t\t\t\t<directory>..\/migrations\/<\/directory>\n\t\t\t<\/exclude>\n\t\t<\/whitelist>\n\t<\/filter>/g;p;}' .github/phpunit-$DB-github.xml &> phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml
else
mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_
fi
working-directory: ./phpBB3

- name: Run unit tests
env:
DB: ${{steps.database-type.outputs.db}}
run: phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php
COVERAGE: ${{ matrix.COVERAGE != 1 && '0' || '1' }}
run: |
if [ $COVERAGE == '1' ]
then
phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php --coverage-clover build/logs/clover.xml
else
phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php
fi
working-directory: ./phpBB3

- name: Send code coverage
if: ${{ matrix.COVERAGE == 1 }}
uses: codecov/codecov-action@v3
with:
files: ./phpBB3/build/logs/clover.xml
# END MySQL and MariaDB Job

# START PostgreSQL Job
postgres-tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
matrix:
include:
Expand All @@ -221,6 +256,20 @@ jobs:
db: "postgres:12"
- php: '7.1'
db: "postgres:13"
- php: '7.2'
db: "postgres:13"
- php: '7.3'
db: "postgres:13"
- php: '7.4'
db: "postgres:13"
- php: '8.0'
db: "postgres:12"
- php: '8.0'
db: "postgres:13"
- php: '8.1'
db: "postgres:14"
- php: '8.2'
db: "postgres:14"

name: PHP ${{ matrix.php }} - ${{ matrix.db }}

Expand Down Expand Up @@ -252,14 +301,14 @@ jobs:

steps:
- name: Checkout phpBB
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: phpbb/phpbb
ref: ${{ env.PHPBB_BRANCH }}
path: phpBB3

- name: Checkout extension
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}

Expand All @@ -268,7 +317,7 @@ jobs:
MATRIX_DB: ${{ matrix.db }}
run: |
db=$(echo "${MATRIX_DB%%:*}")
echo "::set-output name=db::$db"
echo "db=$db" >> $GITHUB_OUTPUT
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -305,7 +354,7 @@ jobs:

# START Other Tests Job (SQLite 3 and mssql)
other-tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
matrix:
include:
Expand Down Expand Up @@ -347,14 +396,14 @@ jobs:

steps:
- name: Checkout phpBB
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: phpbb/phpbb
ref: ${{ env.PHPBB_BRANCH }}
path: phpBB3

- name: Checkout extension
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}

Expand All @@ -368,7 +417,7 @@ jobs:
else
db=$(echo "${MATRIX_DB%%:*}")
fi
echo "::set-output name=db::$db"
echo "db=$db" >> $GITHUB_OUTPUT
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Matomo Analytics Extension

A phpBB extension that allows administrators to easily add Matomo Analytics to their forums. This is a fork of the official phpbb-googleanalytics
extention.
extention.

[![Build Status](https://github.com/Cube707/phpbb-matomoanalytics/workflows/Tests/badge.svg)](https://github.com/Cube707/phpbb-matomoanalytics/actions)
[![codecov](https://codecov.io/gh/Cube707/phpbb-matomoanalytics/branch/master/graph/badge.svg?token=1HQh953sBs)](https://codecov.io/gh/Cube707/phpbb-matomoanalytics)

## Install

Expand All @@ -20,4 +21,4 @@ extention.
3. To permanently uninstall, click `Delete Data` and then delete the `/ext/cube/matomoanalytics` directory.

## License
[GNU General Public License v2](http://opensource.org/licenses/GPL-2.0)
[GNU General Public License v2](https://opensource.org/licenses/GPL-2.0)
56 changes: 56 additions & 0 deletions tests/ext_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
*
* Google Analytics extension for the phpBB Forum Software package.
*
* @copyright (c) 2014, 2022 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace cube\matomoanalytics\tests\system;

class ext_test extends \phpbb_test_case
{
/** @var \PHPUnit\Framework\MockObject\MockObject|\Symfony\Component\DependencyInjection\ContainerInterface */
protected $container;

/** @var \PHPUnit\Framework\MockObject\MockObject|\phpbb\finder */
protected $extension_finder;

/** @var \PHPUnit\Framework\MockObject\MockObject|\phpbb\db\migrator */
protected $migrator;

/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();

// Stub the container
$this->container = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
->disableOriginalConstructor()
->getMock();

// Stub the ext finder and disable its constructor
$this->extension_finder = $this->getMockBuilder('\phpbb\finder')
->disableOriginalConstructor()
->getMock();

// Stub the migrator and disable its constructor
$this->migrator = $this->getMockBuilder('\phpbb\db\migrator')
->disableOriginalConstructor()
->getMock();
}

/**
* Test the extension will be enabled with a compatible version of phpBB
*/
public function test_enable()
{
$ext = new \cube\matomoanalytics\ext($this->container, $this->extension_finder, $this->migrator, 'cube/matomoanalytics', '');

self::assertTrue($ext->is_enableable());
}
}

0 comments on commit 6300548

Please sign in to comment.