Skip to content

Commit

Permalink
Linting and documenting the code (#23)
Browse files Browse the repository at this point in the history
- Adding docblocks
- Fixing some coding style and linting issues
- Rearranging and improving the Composer file
- Adding a Database class to handle database operations and checks
- Removing the cleanup class as it was unused
- Fixing readme a bit
  • Loading branch information
aldavigdis authored Mar 21, 2024
1 parent 065b44b commit bbfc524
Show file tree
Hide file tree
Showing 15 changed files with 551 additions and 101 deletions.
2 changes: 2 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

require_once 'vendor/autoload.php';

# The WP test suite assumes the existence of classes that only exist in
Expand Down
35 changes: 24 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,50 @@
"description": "Strap the WordPress PHPUnit tests library onto your plugin or theme with this handy Composer package.",
"version": "0.1.4",
"type": "library",
"license": "AGPL-3.0-or-later",
"keywords": ["wordpress", "phpunit", "testing", "dev"],
"homepage": "https://github.com/aldavigdis/wp-tests-strapon",
"support": {
"issues": "https://github.com/aldavigdis/wp-tests-strapon/issues",
"source": "https://github.com/aldavigdis/wp-tests-strapon",
"email": "[email protected]"
},
"authors": [
{
"name": "Alda Vigdís Skarphéðinsdóttir",
"email": "[email protected]",
"role": "Developer"
}
],
"require": {
"composer-plugin-api": "^2.6",
"yoast/phpunit-polyfills": "^2.0",
"simoneast/simple-ansi-colors": "^1.0"
"simoneast/simple-ansi-colors": "^1.0",
"phpunit/phpunit": "^9.0 || ^10.0"
},
"require-dev": {
"composer/composer": "^2.7",
"psy/psysh": "^0.12.0",
"wp-coding-standards/wpcs": "^3.0",
"squizlabs/php_codesniffer": "^3.8",
"phpunit/phpunit": "^10.0"
"phpunit/phpunit": "^10.0",
"slevomat/coding-standard": "^8.14",
"phpcompatibility/php-compatibility": "^9.3"

},
"license": "AGPL-3.0-or-later",
"autoload": {
"psr-4": {
"Aldavigdis\\WpTestsStrapon\\": "src/"
}
},
"authors": [
{
"name": "Alda Vigdís Skarphéðinsdóttir",
"email": "[email protected]"
}
],
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"extra": {
"class": "Aldavigdis\\WpTestsStrapon\\StraponMain"
"scripts": {
"test": "./vendor/bin/phpunit --testdox --display-warnings --display-notices",
"lint:check": "vendor/bin/phpcs src/ bootstrap.php tests/",
"lint:fix": "vendor/bin/phpcbf src/ bootstrap.php tests/"
}
}
188 changes: 181 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 42 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
<?xml version="1.0"?>
<ruleset name="WP-Tests-Strapon">
<rule ref="Generic.Files.OneObjectStructurePerFile.MultipleFound">
<exclude-pattern>./supressors/*</exclude-pattern>

<rule ref="PHPCompatibility">
</rule>
<config name="testVersion" value="8.2-"/>

<!-- Enforce strict type decleration at top of all PHP files -->
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="spacesCountAroundEqualsSign" value="0" />
<property name="linesCountBeforeDeclare" value="1" />
<property name="linesCountAfterDeclare" value="1" />
</properties>
</rule>

<!-- Enforce type hinting for function parameters -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
</rule>

<!-- Enforce type hinting for function return values -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
</rule>

<!-- Disallow "sloppy" equals operators -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators">
</rule>

<!--
Exclude the vendor direcotry because of course
-->
<exclude-pattern>./vendor/*</exclude-pattern>

<!--
Excluding commenting rules from tests, as we are using TestDox instead
-->
<rule ref="Squiz.Commenting.ClassComment.Missing">
<exclude-pattern>./tests/**</exclude-pattern>
<exclude-pattern>./supressors/**</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.Missing">
<exclude-pattern>./tests/**</exclude-pattern>
<exclude-pattern>./supressors/**</exclude-pattern>
</rule>

</ruleset>
Loading

0 comments on commit bbfc524

Please sign in to comment.