Skip to content

Commit

Permalink
chore: add tests, PHPStan and associated fixes (#73)
Browse files Browse the repository at this point in the history
* chore: add tests

* Apply fixes from StyleCI

* comment troublesome test for a moment

* current tests passing

* try php8 tests only

* php 7.x compat

* Apply fixes from StyleCI

* also test reaction is saved in the db

* without permission tests

* Apply fixes from StyleCI

* add phpstan, address most of the issues

* Apply fixes from StyleCI

* no stan errors now?

* add crud tests, minor fixes

* Apply fixes from StyleCI

* remove typing directly

* don't resolve in the constructor

* Apply fixes from StyleCI

* test disabled reactions

* let composer decide on flarum/phpstan ver

* drop php 7.3 support

* list reactions test

* Apply fixes from StyleCI

* post attribute test

* Apply fixes from StyleCI

* list post reactions test

* Apply fixes from StyleCI

* npm audit fix

* fix: show post reactions controller not respecting permission

* allow guests to have view post reaction permission

* Apply fixes from StyleCI

* initial flarum/likes integration test

* another couple of likes tests

---------

Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
imorland and StyleCIBot authored Oct 22, 2023
1 parent ef22c73 commit 156ba9e
Show file tree
Hide file tree
Showing 40 changed files with 1,740 additions and 311 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: FoF Reactions PHP

on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@main
with:
enable_backend_testing: true
enable_phpstan: true
backend_directory: .
php_versions: '["7.4", "8.0", "8.1", "8.2"]'
31 changes: 0 additions & 31 deletions .github/workflows/build.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: FoF Reactions JS

on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@main
with:
enable_bundlewatch: false
enable_prettier: true
enable_typescript: true

frontend_directory: ./js
backend_directory: .
js_package_manager: npm
main_git_branch: master

secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ bower_components
.floo*
js/dist
composer.lock
.phpunit.result.cache
36 changes: 36 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
}
],
"require": {
"php": "^7.4 | ^8.0",
"flarum/core": "^1.2.0"
},
"replace": {
Expand Down Expand Up @@ -59,6 +60,41 @@
},
"flagrow": {
"discuss": "https://discuss.flarum.org/d/20655"
},
"flarum-cli": {
"modules": {
"backendTesting": true,
"githubActions": true
}
}
},
"autoload-dev": {
"psr-4": {
"FoF\\Reactions\\Tests\\": "tests/"
}
},
"scripts": {
"test": [
"@test:unit",
"@test:integration"
],
"test:unit": "phpunit -c tests/phpunit.unit.xml",
"test:integration": "phpunit -c tests/phpunit.integration.xml",
"test:setup": "@php tests/integration/setup.php",
"analyse:phpstan": "phpstan analyse",
"clear-cache:phpstan": "phpstan clear-result-cache"
},
"scripts-descriptions": {
"test": "Runs all tests.",
"test:unit": "Runs all unit tests.",
"test:integration": "Runs all integration tests.",
"test:setup": "Sets up a database for use with integration tests. Execute this only once.",
"analyse:phpstan": "Run static analysis"
},
"require-dev": {
"flarum/testing": "^1.0.0",
"flarum/likes": "*",
"fof/gamification": "*",
"flarum/phpstan": "*"
}
}
2 changes: 1 addition & 1 deletion extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
}),

(new Extend\ApiController(ApiController\ShowForumController::class))
->prepareDataForSerialization(function (ApiController\ShowForumController $controller, &$data, $request, $document) {
->prepareDataForSerialization(function (ApiController\ShowForumController $controller, &$data) {
$data['reactions'] = Reaction::get();
}),

Expand Down
Loading

0 comments on commit 156ba9e

Please sign in to comment.