helsingborg-stad / api-alarm-manager
Installs: 239
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 11
Forks: 1
Open Issues: 1
Type:wordpress-plugin
Requires
- php: >=8.1
- helsingborg-stad/acf-export-manager: ^1.0.12
- helsingborg-stad/coordinate-transformation-library: ^1.0.1
- phpseclib/phpseclib: ^3.0.0
Requires (Dev)
- 10up/wp_mock: ^1.0
- helsingborg-stad/phpcs: ^0.2.2
- lucatume/function-mocker: ^1.3
- dev-main
- 2.2.3
- 2.2.2
- 2.1.2
- 2.1.1
- 2.0.2
- 2.0.1
- 1.3.7
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.28
- 1.1.27
- 1.1.26
- 1.1.25
- 1.1.24
- 1.1.23
- 1.1.22
- 1.1.21
- 1.1.20
- 1.1.19
- 1.1.18
- 1.1.17
- 1.1.16
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.2.12
- 0.2.11
- 0.2.10
- 0.2.9
- 0.2.8
- 0.2.7
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-feat/allow-cors
- dev-dependabot/composer/phpseclib/phpseclib-3.0.36
- dev-chore/vendor
- dev-fix/sftp
- dev-fix/version-bump
- dev-fix/import-address-warning
- dev-feat/brandrisk-CU-865c1qym6
- dev-fix/upgrade-phpseclib
- dev-feat/support-sftp-CU-865bkuxzh
- dev-develop
This package is auto-updated.
Last update: 2024-12-22 10:13:07 UTC
README
Creates WordPress Rest API endpoints for contal alarms and fire danger levels.
Alarms
Alarms are imported from a remote FTP/SFTP server. The alarms are then stored in the WordPress database and can be fetched from the WordPress Rest API.
After the alarms have been imported, they are moved to an archive folder on the remote server. For the alarms to be archived on the remote server, the const API_ALARM_MANAGER_ARCHIVE_ALARMS_ON_REMOTE
must be set to true
. Otherwise the alarm files on the remote server will note be altered.
Fire danger levels
Fire danger levels are posts that are created in WordPress. The posts are then fetched from the WordPress Rest API.
Constants
define('API_ALARM_MANAGER_ARCHIVE_ALARMS_ON_REMOTE', true); - REQUIRED to archive alarms on remote server.
Devcontainer
This project uses a devcontainer for development. This means that you can use VS Code to develop the project. To use the devcontainer, you need to install the Remote - Containers extension for VS Code. When you have installed the extension, you can open the project in a container by clicking the green button in the bottom left corner of VS Code and select "Remote-Containers: Reopen in Container".
Devcontainer ftp/sftp services
To make it easier to test this plugins functionality on your local machine you can use the ftp/sftp services that are installed in the devcontainer. The services and their credentials are listed in the ./devcontainer/docker-compose.yml
file.
Use the following details to set up a connection to either ftp or sftp from the WordPress admin panel:
SFTP
- server: sftp
- username: demo
- password: demo
- FTP/SFTP folder: /files
- FTP/SFTP archive folder: /archive
FTP
- server: ftp
- username: demo
- password: demo
- FTP/SFTP folder: /files
- FTP/SFTP archive folder: /archive
Devcontainer ftp/sftp test files
A number of files for testing locally are available in the ./devcontainer/remoteFiles
. To prepare or reset test files run the shell script ./.vscode/tasks/reset-dummy-files
from the terminal:
sh ./vscode/tasks/reset-dummy-files.sh
PHP Tests
Municipio uses PHPUnit for unit testing. For mocking and stubbing we use WP_Mock. This means that you can use WP_Mock, Mockery(since this is a wrapper for WP_Mock) and PHPUnit_MockObject for mocking and stubbing.
PHPUnit Tests file structure
All tests are stored in the tests/phpunit/tests
folder. The file structure should mirror the file structure of the theme. The file name should be the same as the file you want to test. For example, if you want to test the file src/Controller/Base.php
you should create the file tests/phpunit/tests/Controller/Base.php
. To avoid having too large test files, you can instead create a folder with the same name as the file you want to test and put the test files inside. Please note that for separating files by which class function you are testing, you should name the file e.g. Base.functionName.php
.
Running PHPUnit tests
Run composer test
in the terminal.
Running PHPUnit tests with code coverage
Run composer test:coverage
in the terminal. This will generate a code coverage report in the tests/phpunit/.coverage
folder.