Skip to content

Commit

Permalink
Merge pull request #2 from EnhancedAthlete/dev
Browse files Browse the repository at this point in the history
Bugfix + updated dev+test config
  • Loading branch information
BrianHenryIE authored Aug 29, 2020
2 parents b275dc7 + 9eef44d commit c1cecfd
Show file tree
Hide file tree
Showing 68 changed files with 8,154 additions and 2,488 deletions.
19 changes: 19 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
PLUGIN_NAME="EA WP AWS SES Bounce Handler"
PLUGIN_SLUG=ea-wp-aws-ses-bounce-handler
WP_ROOT_FOLDER="wordpress"
TEST_SITE_WP_ADMIN_PATH="/wp-admin"
TEST_SITE_DB_NAME="ea_wp_aws_ses_bounce_handler_tests"
TEST_SITE_DB_HOST="127.0.0.1"
TEST_SITE_DB_USER="ea-wp-aws-ses-bounce-handler"
TEST_SITE_DB_PASSWORD="ea-wp-aws-ses-bounce-handler"
TEST_SITE_TABLE_PREFIX="wp_"
TEST_DB_NAME="ea_wp_aws_ses_bounce_handler_integration"
TEST_DB_HOST="127.0.0.1"
TEST_DB_USER="ea-wp-aws-ses-bounce-handler"
TEST_DB_PASSWORD="ea-wp-aws-ses-bounce-handler"
TEST_TABLE_PREFIX="wp_"
TEST_SITE_WP_URL="http://localhost/ea-wp-aws-ses-bounce-handler/"
TEST_SITE_WP_DOMAIN="localhost"
TEST_SITE_ADMIN_EMAIL="BrianHenryIE@gmail.com"
TEST_SITE_ADMIN_USERNAME="admin"
TEST_SITE_ADMIN_PASSWORD="password"
54 changes: 47 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,52 @@
.idea
*.phar
scratch*
# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~
*.sass-cache

# OS or Editor folders
.DS_Store
vendor/*
releases
wp-content
*.zip
Thumbs.db
.cache
.project
.settings
.tmproj
*.esproj
nbproject
*.sublime-project
*.sublime-workspace

# Dreamweaver added files
_notes
dwsync.xml

# Komodo
*.komodoproject
.komodotools

# Folders to ignore
.hg
.svn
.CVS
intermediate
.idea
cache

/vendor/


wordpress
src/vendor/
src/dependencies/
wp-content/

scratch


.env.secret
4 changes: 4 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*ea-wp-aws-ses-bounce-handler$ [NC,OR]
RewriteCond %{REQUEST_URI} !wordpress/
RewriteRule (.*) wordpress/$1 [L]
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Changelog

63 changes: 61 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,68 @@ function add_my_integration( $integrations ) {
}
```

## Development
## Contributing

See [BrianHenryIE/wordpress-plugin-boilerplate](https://github.com/brianhenryie/wordpress-plugin-boilerplate) repo for developer notes.
Clone this repo, open PhpStorm, then run `composer install` to install the dependencies.

```
git clone https://github.com/enhancedathlete/ea-wp-aws-ses-bounce-handler.git;
open -a PhpStorm ./;
composer install;
```

For integration and acceptance tests, a local webserver must be running with `localhost/ea-wp-aws-ses-bounce-handler/` pointing at the root of the repo. MySQL must also be running locally – with two databases set up with:

```
mysql_username="root"
mysql_password="secret"
# export PATH=${PATH}:/usr/local/mysql/bin
# Make .env available to bash.
export $(grep -v '^#' .env.testing | xargs)
# Create the databases.
mysql -u $mysql_username -p$mysql_password -e "CREATE USER '"$TEST_DB_USER"'@'%' IDENTIFIED WITH mysql_native_password BY '"$TEST_DB_PASSWORD"';";
mysql -u $mysql_username -p$mysql_password -e "CREATE DATABASE "$TEST_SITE_DB_NAME"; USE "$TEST_SITE_DB_NAME"; GRANT ALL PRIVILEGES ON "$TEST_SITE_DB_NAME".* TO '"$TEST_DB_USER"'@'%';";
mysql -u $mysql_username -p$mysql_password -e "CREATE DATABASE "$TEST_DB_NAME"; USE "$TEST_DB_NAME"; GRANT ALL PRIVILEGES ON "$TEST_DB_NAME".* TO '"$TEST_DB_USER"'@'%';";
```

### WordPress Coding Standards

See documentation on [WordPress.org](https://make.wordpress.org/core/handbook/best-practices/coding-standards/) and [GitHub.com](https://github.com/WordPress/WordPress-Coding-Standards).

Correct errors where possible and list the remaining with:

```
vendor/bin/phpcbf; vendor/bin/phpcs
```

### Tests

Tests use the [Codeception](https://codeception.com/) add-on [WP-Browser](https://github.com/lucatume/wp-browser) and include vanilla PHPUnit tests with [WP_Mock](https://github.com/10up/wp_mock).

Run tests with:

```
vendor/bin/codecept run unit;
vendor/bin/codecept run wpunit;
vendor/bin/codecept run integration;
vendor/bin/codecept run acceptance;
```

To save changes made to the acceptance database:

```
export $(grep -v '^#' .env.testing | xargs)
mysqldump -u $TEST_SITE_DB_USER -p$TEST_SITE_DB_PASSWORD $TEST_SITE_DB_NAME > tests/_data/dump.sql
```

To clear Codeception cache after moving/removing test files:

```
vendor/bin/codecept clean
```

## Acknowledgements

Expand Down
28 changes: 28 additions & 0 deletions codeception.dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
commands:
- Codeception\Command\GenerateWPUnit
- Codeception\Command\GenerateWPRestApi
- Codeception\Command\GenerateWPRestController
- Codeception\Command\GenerateWPRestPostTypeController
- Codeception\Command\GenerateWPAjax
- Codeception\Command\GenerateWPCanonical
- Codeception\Command\GenerateWPXMLRPC
params:
- .env.testing
coverage:
enabled: true
include:
- src/*
exclude:
- src/dependencies/*
- src/vendor/*
bootstrap: bootstrap.php
62 changes: 47 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
"description": "Unsubscribe users from email lists when AWS SES sends a bounce or complaint report.",
"type": "wordpress-plugin",
"license": "GPL-2.0+-or-later",
"authors": [
{
"name": "Brian Henry",
"email": "BrianHenryIE@gmail.com"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"process-timeout": 0
},
"repositories": [
{
"url": "https://github.com/WordPress/wordpress-develop",
Expand All @@ -26,29 +37,46 @@
}
],
"require": {
"php": ">=7.2",
"brianhenryie/wppb-lib": "dev-master",
"pablo-sg-pacheco/wp-namespace-autoloader": "dev-master"
},
"require-dev": {
"10up/wp_mock": "0.4.2",
"brianhenryie/composer-phpstorm": "dev-master",
"cweagans/composer-patches": "^1.0",
"coenjacobs/mozart": "0.5.1",
"wordpress/wordpress": ">=5.4",
"dealerdirect/phpcodesniffer-composer-installer": "*",
"codeception/module-db": "^1.0.0",
"codeception/module-phpbrowser": "^1.0.0",
"codeception/module-webdriver": "^1.0",
"codeception/module-filesystem": "^1.0",
"codeception/util-universalframework": "^1.0",
"codeception/module-cli": "^1.0",
"coenjacobs/mozart": "dev-master",
"cweagans/composer-patches": "~1.0",
"jaschilz/php-coverage-badger": "^2.0",
"kporras07/composer-symlinks": "dev-master",
"phpunit/phpunit" : "^7.5",
"10up/wp_mock": "0.4.2",
"phpunit/phpunit": ">=7.0",
"phpunit/phpcov": "^5.0",
"phpcompatibility/phpcompatibility-wp": "*",
"dealerdirect/phpcodesniffer-composer-installer": "*",
"lucatume/wp-browser": "*",
"codeception/module-asserts": "^1.0",
"wordpress/wordpress": "^5.4",
"wp-coding-standards/wpcs": "*",
"wpackagist-plugin/mailpoet":"*",
"wpackagist-plugin/newsletter":"*",
"woocommerce/woocommerce": ">4"
"wpackagist-theme/twentytwenty": "*",
"wpackagist-theme/storefront": "*",
"wpackagist-plugin/woocommerce": ">4",
"voku/portable-ascii": "dev-master"
},
"extra": {
"patches": {
"coenjacobs/mozart": {
"Allow default packages" : "https://github.com/coenjacobs/mozart/pull/34.patch",
"Add config option to disable deleting vendor directories": "https://github.com/coenjacobs/mozart/pull/38.patch"
"DIRECTORY_SEPARATOR": "https://github.com/coenjacobs/mozart/pull/61.patch",
"Delete empty directories": "https://github.com/coenjacobs/mozart/pull/59.patch"
},
"jaschilz/php-coverage-badger": {
"Allow customising the text": "https://github.com/JASchilz/PHPCoverageBadge/pull/1.patch"
}
},
"mozart": {
Expand All @@ -59,15 +87,15 @@
"delete_vendor_directories": false
},
"symlinks": {
"src": "wp-content/plugins/ea-wp-aws-ses-bounce-handler",
"vendor/wordpress/wordpress/src": "wordpress"
"wp-content": "wordpress/wp-content",
"src": "wp-content/plugins/ea-wp-aws-ses-bounce-handler"
},
"phpstorm": {
"exclude_folders": {
"folders": [
"vendor/wordpress/wordpress/src",
"vendor/wordpress/wordpress/build",
"wordpress/wp-content/plugins",
"wordpress/wp-content",
"wp-content/plugins/ea-wp-aws-ses-bounce-handler"
],
"include_folders": [
Expand All @@ -80,17 +108,21 @@
"scripts": {
"post-install-cmd": [
"\"vendor/bin/mozart\" compose",
"vendor/bin/wp core download --path=wordpress || true;",
"export $(grep -v '^#' .env.testing | xargs); vendor/bin/wp config create --dbname=$TEST_SITE_DB_NAME --dbuser=$TEST_SITE_DB_USER --dbpass=$TEST_SITE_DB_PASSWORD || true",
"Kporras07\\ComposerSymlinks\\ScriptHandler::createSymlinks",
"mkdir -p vendor/wordpress/wordpress/src/wp-content/uploads",
"mkdir -p wordpress/wp-content/uploads",
"BrianHenryIE\\ComposerPhpStorm\\ExcludeFolders::update",
"BrianHenryIE\\ComposerPhpStorm\\PHPUnitRunConfigurations::update"
],
"post-update-cmd": [
"\"vendor/bin/mozart\" compose",
"vendor/bin/wp core download --path=wordpress || true;",
"export $(grep -v '^#' .env.testing | xargs); vendor/bin/wp config create --dbname=$TEST_SITE_DB_NAME --dbuser=$TEST_SITE_DB_USER --dbpass=$TEST_SITE_DB_PASSWORD || true",
"Kporras07\\ComposerSymlinks\\ScriptHandler::createSymlinks",
"mkdir -p vendor/wordpress/wordpress/src/wp-content/uploads",
"mkdir -p wordpress/wp-content/uploads",
"BrianHenryIE\\ComposerPhpStorm\\ExcludeFolders::update",
"BrianHenryIE\\ComposerPhpStorm\\PHPUnitRunConfigurations::update"
]
}
}
}
Loading

0 comments on commit c1cecfd

Please sign in to comment.