Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aiiddqd/testeroid
Auto tests and TDD for WordPress & WooCommerce with WP CLI
https://github.com/aiiddqd/testeroid
pestphp phpunit test-automation testing woocommerce wordpress
Last synced: about 8 hours ago
JSON representation
Auto tests and TDD for WordPress & WooCommerce with WP CLI
- Host: GitHub
- URL: https://github.com/aiiddqd/testeroid
- Owner: aiiddqd
- Created: 2022-12-14T06:06:16.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-31T16:03:49.000Z (about 1 year ago)
- Last Synced: 2024-05-10T18:28:44.787Z (8 months ago)
- Topics: pestphp, phpunit, test-automation, testing, woocommerce, wordpress
- Language: PHP
- Homepage: https://wpcraft.ru/
- Size: 2.64 MB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Testeroid
It is simple plugin to getting auto tests and TDD by WP CLI
inspired by Laravel & https://pestphp.com/
demo https://github.com/wpcraft-ru/wooms/tree/master/tests
support and questions https://github.com/uptimizt/testeroid/issues
# why?
It doesn't always make sense to configure complex PHP Unit for simple testing
| Comparison | Testeroid | PHPUnit | PestPHP |
| --- | --- | --- | --- |
| Time to install and config | 1 min | 1-2 weeks | 1-2 weeks |
| Learning curve | 1 day | 1-2 months | 1-2 months |
| modern syntax | + | - | + |
| WP CLI support | + | - | - |
| simple bootstrap | + | - | - |
| universal testing for App, Plugin or Theme | + | - | - |# how?
## installation
- install plugin `wp plugin install https://github.com/uptimizt/testeroid/archive/main.zip --activate --force`
- make folder `tests` in plugin, or theme, or for whole site
- set constant `TESTEROID_TESTS_PATH` in wp-config.php to path of tests
- exmaple `define('TESTEROID_TESTS_PATH', __DIR__ . "/path/to/tests/")`
- via wp cli `wp config set TESTEROID_TESTS_PATH '__DIR__ . "/path/to/tests/"' --raw`## write tests
like PestPHP
### feature test example
```
//file ./tests/SomeComponent.phpnamespace App\Tests\SomeComponent;
use function Testeroid\{test, transaction_query};
transaction_query('start');
test('simple test', function(){
$post_data = [
'post_title' => 'test 1',
'post_content' => 'test',
'post_status' => 'publish',
];// Insert the post into the database
$post_id = wp_insert_post( $post_data );
$post = get_post($post_id);if($post->post_title === 'test 1'){
return true;
} else {
return false;
}}, 1);
transaction_query('rollback');
```### unit test example
```