-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,41 @@ | ||
# Static Analysis | ||
# Testing | ||
|
||
## Static Analysis | ||
|
||
To run static analysis on the plugin, install PHPStan and run the following command from the root of your project. | ||
To run static analysis on the plugin, | ||
install [PHPStan for Craft CMS](https://github.com/craftcms/phpstan) and run the | ||
following command from the root of your project. | ||
|
||
```shell | ||
./vendor/bin/phpstan analyse -c vendor/putyourlightson/craft-snaptcha/phpstan.neon | ||
./vendor/bin/phpstan analyse -c vendor/putyourlightson/craft-snaptcha/phpstan.neon --memory-limit 1G | ||
``` | ||
|
||
# Testing | ||
## Easy Coding Standard | ||
|
||
To test the plugin, install Codeception, update `.env` and run the following command from the root of your project. | ||
To run the Easy Coding Standard on the plugin, | ||
install [ECS for Craft CMS](https://github.com/craftcms/ecs) and run the | ||
following command from the root of your project. | ||
|
||
```shell | ||
./vendor/bin/codecept run -c ./vendor/putyourlightson/craft-snaptcha unit | ||
./vendor/bin/ecs check -c vendor/putyourlightson/craft-snaptcha/ecs.php | ||
``` | ||
|
||
Or to run a specific test. | ||
## Pest Tests | ||
|
||
To run Pest tests, first install [Craft Pest](https://craft-pest.com/) core as a dev dependency. | ||
|
||
```shell | ||
./vendor/bin/codecept run -c ./vendor/putyourlightson/craft-snaptcha unit variables/SnaptchaVariableTest:getField | ||
composer require markhuot/craft-pest-core:^2.0.0-rc2 --dev | ||
``` | ||
|
||
> Ensure that the database you specify in `.env` is not one that actually contains any data as it will be cleared when the tests are run. | ||
Then run the following command from the root of your project. | ||
|
||
```shell | ||
php php vendor/bin/pest --test-directory=vendor/putyourlightson/craft-snaptcha/tests/pest | ||
``` | ||
|
||
Or to run a specific test. | ||
|
||
```shell | ||
php php vendor/bin/pest --test-directory=vendor/putyourlightson/craft-snaptcha/tests/pest --filter=CacheRequestTest | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Test Specification | ||
|
||
This document outlines the test specification for the Snaptcha plugin. | ||
|
||
--- | ||
|
||
## Architecture Tests | ||
|
||
### [Architecture](pest/Architecture/ArchitectureTest.php) | ||
|
||
_Tests the architecture of the plugin._ | ||
|
||
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Source code does not contain any “dump or die” statements. | ||
|
||
## Feature Tests | ||
|
||
### [Allowed](pest/Feature/AllowedTest.php) | ||
|
||
_Tests whether performing actions is allowed._ | ||
|
||
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) User is not allowed when validation is enabled. | ||
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) User is allowed when validation is disabled. | ||
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) User IP is allowed when in the allow list. | ||
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) User IP is allowed when in a nested array in the allow list. | ||
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) User IP is not allowed when not in the allow list. | ||
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) User IP is denied when in the deny list. | ||
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) User IP is denied when in a nested array in the deny list. | ||
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) User IP is not denied when not in the deny list. | ||
|
||
### [SnaptchaVariable](pest/Feature/SnaptchaVariableTest.php) | ||
|
||
_Tests the markup generated by the Snaptcha variable._ | ||
|
||
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Field is named after field name setting. |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/test-results.xml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
/** | ||
* Tests the architecture of the plugin. | ||
*/ | ||
|
||
test('Source code does not contain any “dump or die” statements') | ||
->expect(['var_dump', 'die']) | ||
->not->toBeUsed(); |