-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from deliciousbrains/add-unit-tests
Add unit tests
- Loading branch information
Showing
13 changed files
with
2,617 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
workflows: | ||
version: 2 | ||
main: | ||
jobs: | ||
- php72-build | ||
- php73-build | ||
- php74-build | ||
- php80-build | ||
|
||
version: 2 | ||
|
||
job-references: | ||
mysql_image: &mysql_image | ||
cimg/mysql:5.7 | ||
|
||
setup_environment: &setup_environment | ||
name: "Setup Environment Variables" | ||
command: | | ||
echo "export PATH=$HOME/.composer/vendor/bin:$PATH" >> $BASH_ENV | ||
source /home/circleci/.bashrc | ||
install_dependencies: &install_dependencies | ||
name: "Install Dependencies" | ||
command: | | ||
sudo apt-get update && sudo apt-get install mysql-client subversion | ||
php_job: &php_job | ||
environment: | ||
- WP_TESTS_DIR: "/tmp/wordpress-tests-lib" | ||
- WP_CORE_DIR: "/tmp/wordpress/" | ||
steps: | ||
- checkout | ||
- run: php --version | ||
- run: composer --version | ||
- run: *setup_environment | ||
- run: *install_dependencies | ||
- run: | ||
name: "Run Tests" | ||
command: | | ||
rm -rf $WP_TESTS_DIR $WP_CORE_DIR | ||
bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest | ||
make test-unit | ||
WP_MULTISITE=1 make test-unit | ||
make test-style | ||
jobs: | ||
php56-build: | ||
<<: *php_job | ||
docker: | ||
- image: cimg/php:5.6 | ||
- image: *mysql_image | ||
|
||
php70-build: | ||
<<: *php_job | ||
docker: | ||
- image: cimg/php:7.0 | ||
- image: *mysql_image | ||
|
||
php71-build: | ||
<<: *php_job | ||
docker: | ||
- image: cimg/php:7.1 | ||
- image: *mysql_image | ||
|
||
php72-build: | ||
<<: *php_job | ||
docker: | ||
- image: cimg/php:7.2 | ||
- image: *mysql_image | ||
|
||
php73-build: | ||
<<: *php_job | ||
docker: | ||
- image: cimg/php:7.3 | ||
- image: *mysql_image | ||
|
||
php74-build: | ||
<<: *php_job | ||
docker: | ||
- image: cimg/php:7.4 | ||
- image: *mysql_image | ||
|
||
php80-build: | ||
<<: *php_job | ||
docker: | ||
- image: cimg/php:8.0 | ||
- image: *mysql_image | ||
|
||
php81-build: | ||
<<: *php_job | ||
docker: | ||
- image: cimg/php:8.1 | ||
- image: *mysql_image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/vendor/ | ||
/.idea | ||
/.idea | ||
*.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="WordPress Coding Standards based custom ruleset for your plugin"> | ||
<description>Generally-applicable sniffs for WordPress plugins.</description> | ||
|
||
<!-- What to scan --> | ||
<file>.</file> | ||
<exclude-pattern>/vendor/</exclude-pattern> | ||
<exclude-pattern>/node_modules/</exclude-pattern> | ||
<exclude-pattern>/tests/*</exclude-pattern> | ||
|
||
<!-- How to scan --> | ||
<!-- Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage --> | ||
<!-- Annotated ruleset: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml --> | ||
<arg value="sp"/> <!-- Show sniff and progress --> | ||
<arg name="basepath" value="./"/><!-- Strip the file paths down to the relevant bit --> | ||
<arg name="colors"/> | ||
<arg name="extensions" value="php"/> | ||
<arg name="parallel" value="8"/><!-- Enables parallel processing when available for faster results. --> | ||
|
||
<!-- Rules: Check PHP version compatibility --> | ||
<!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions --> | ||
<config name="testVersion" value="7.2-"/> | ||
<!-- https://github.com/PHPCompatibility/PHPCompatibilityWP --> | ||
<rule ref="PHPCompatibilityWP"/> | ||
|
||
<!-- Rules: WordPress Coding Standards --> | ||
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards --> | ||
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties --> | ||
<config name="minimum_supported_wp_version" value="4.6"/> | ||
<rule ref="WordPress"> | ||
<!-- Unable to fix --> | ||
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/> | ||
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound"/> | ||
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound"/> | ||
<exclude name="WordPress.DB.DirectDatabaseQuery.NoCaching"/> | ||
|
||
<!-- TODO: Maybe fix --> | ||
<exclude name="WordPress.WP.CronInterval.ChangeDetected"/> | ||
<exclude name="WordPress.WP.AlternativeFunctions.rand_rand"/> | ||
<exclude name="WordPress.DB.DirectDatabaseQuery.DirectQuery"/> | ||
|
||
<!-- TODO: Should fix --> | ||
<exclude name="WordPress.DB.PreparedSQL.InterpolatedNotPrepared"/> | ||
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"/> | ||
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments"/> | ||
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine"/> | ||
<exclude name="Generic.Commenting.DocComment.SpacingAfter"/> | ||
</rule> | ||
<rule ref="WordPress.NamingConventions.PrefixAllGlobals"> | ||
<properties> | ||
<!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. --> | ||
<property name="prefixes" type="array" value="wpbp"/> | ||
</properties> | ||
|
||
<!-- TODO: Maybe fix --> | ||
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound"/> | ||
</rule> | ||
<rule ref="WordPress.WP.I18n"> | ||
<properties> | ||
<!-- Value: replace the text domain used. --> | ||
<property name="text_domain" type="array" value="wp-background-processing"/> | ||
</properties> | ||
|
||
<!-- TODO: Should fix --> | ||
<exclude name="WordPress.WP.I18n.MissingArgDomain"/> | ||
<exclude name="WordPress.WP.I18n.MissingTranslatorsComment"/> | ||
</rule> | ||
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing"> | ||
<properties> | ||
<property name="blank_line_check" value="true"/> | ||
</properties> | ||
</rule> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.PHONY: test | ||
test: test-unit test-style | ||
|
||
.PHONY: test-unit | ||
test-unit: vendor | ||
vendor/bin/phpunit | ||
|
||
.PHONY: test-style | ||
test-style: vendor | ||
vendor/bin/phpcs | ||
|
||
vendor: composer.json | ||
composer install --ignore-platform-reqs | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf vendor | ||
rm -f tests/.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.