Skip to content

Commit

Permalink
Add phpunit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkeschiren committed Mar 10, 2024
1 parent 2c56dae commit 99c0d5f
Show file tree
Hide file tree
Showing 14 changed files with 1,057 additions and 511 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ tmp/
vendor/
node_modules/
.vscode
tests/.phpunit.result.cache
7 changes: 7 additions & 0 deletions Sentry.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/**
* Sentry, a Matomo plugin by Digitalist Open Tech
*
* @link https://github.com/digitalist-se/MatomoPlugin-Sentry
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Plugins\Sentry;

use Piwik\Config;
Expand Down
9 changes: 8 additions & 1 deletion SystemSettings.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/**
* Sentry, a Matomo plugin by Digitalist Open Tech
*
* @link https://github.com/digitalist-se/MatomoPlugin-Sentry
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Plugins\Sentry;

use Piwik\Settings\Setting;
Expand Down Expand Up @@ -200,4 +207,4 @@ function (FieldConfig $field) {
}
);
}
}
}
29 changes: 29 additions & 0 deletions TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,32 @@ Run PHP CodeSniffer
vendor/bin/phpcs --ignore=*/vendor/*,*/node_modules/*,*.js --standard=PSR2 .
vendor/bin/phpcs --ignore=*/vendor/*,*/node_modules/*,*.js --standard=PSR12 .
```

## PHPUnit

Go to plugins/Sentry

```bash
composer install
````

Got to Matomo web root folder (normally `/var/www/html`).

Set up test environment:

```bash
./console development:enable
./console config:set --section=tests --key=http_host --value=web
./console config:set --section=tests --key=request_uri --value=/
./console config:set --section=database_tests --key=host --value=db
./console config:set --section=database_tests --key=username --value=root
./console config:set --section=database_tests --key=password --value=root
./console config:set --section=database_tests --key=dbname --value=matomo_test
./console config:set --section=database_tests --key=tables_prefix --value=""
```

Run tests:

```bash
/var/www/html/plugins/Sentry/vendor/bin/phpunit -c plugins/Sentry/tests/phpunit.xml
```
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
"monolog/monolog": "~1.11"
},
"require-dev": {
"phpunit/phpunit": "9.6.4",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"pheromone/phpcs-security-audit": "^2.0",
"php-webdriver/webdriver": "^1.15",
"squizlabs/php_codesniffer": "^3.7",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpunit/phpunit": "^10.4",
"squizlabs/php_codesniffer": "^3.7",
"pheromone/phpcs-security-audit": "^2.0",
"slevomat/coding-standard": "^8.14"
"slevomat/coding-standard": "^8.8",
"spaze/phpstan-disallowed-calls": "^2.12",
"psr/container": "1.1.2"
},
"config": {
"allow-plugins": {
Expand Down
Loading

0 comments on commit 99c0d5f

Please sign in to comment.