Download the PHP package greys/wc-product-bundles-tests without Composer
On this page you can find all versions of the php package greys/wc-product-bundles-tests. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download greys/wc-product-bundles-tests
More information about greys/wc-product-bundles-tests
Files in greys/wc-product-bundles-tests
Package wc-product-bundles-tests
Short Description PHPUnit testing framework for WooCommerce Product Bundles
License MIT
Informations about the package wc-product-bundles-tests
WooCommerce Product Bundles PHPUnit Framework
A comprehensive PHPUnit testing framework for WooCommerce Product Bundles. This package provides helper classes, custom assertions, and utilities to make testing Product Bundles functionality easier and more reliable.
Features
- Base Test Case: Specialized
UnitTestCasewith automatic cleanup - Helper Classes: Create bundles and bundled items with realistic data
- Custom Assertions: Domain-specific assertions for bundle testing
- Database Support: Works with Product Bundles custom tables
- Realistic Test Data: Examples using production-like data patterns
Installation
Requirements
- PHP 7.4 or higher
- PHPUnit 9.x
- WooCommerce
- WooCommerce Product Bundles
greys/woocommerce-phpunit-framework
Quick Start
1. Extend the Base Test Case
2. Use Helper Classes
3. Use Custom Assertions
Helper Methods
Bundle
Bundle Creation
Bundled Items
Stock Management
Size Limits
Variation Filters
Cleanup
Meta Operations
Available Assertions
Bundle Assertions
| Assertion | Description |
|---|---|
assertIsBundle( $product ) |
Assert product is a bundle |
assertBundleHasItems( $count, $bundle ) |
Assert bundle has specific number of items |
assertProductInBundle( $product_id, $bundle ) |
Assert product is in bundle |
assertBundleVirtual( $bundle ) |
Assert bundle is virtual |
assertBundleLayout( $expected, $bundle ) |
Assert bundle layout style |
assertBundleGroupMode( $expected, $bundle ) |
Assert bundle group mode |
assertBundleEditableInCart( $bundle ) |
Assert bundle is editable in cart |
assertBundleStockQuantity( $expected, $bundle ) |
Assert bundle stock quantity |
assertBundledItemsStockStatus( $expected, $bundle ) |
Assert bundled items stock status |
assertBundleBasePrice( $expected, $bundle ) |
Assert bundle base price |
assertBundleSizeLimits( $min, $max, $bundle ) |
Assert min/max bundle size |
Bundled Item Assertions
| Assertion | Description |
|---|---|
assertBundledItemQuantities( $id, $min, $max, $default ) |
Assert item quantities |
assertBundledItemOptional( $bundled_item_id ) |
Assert item is optional |
assertBundledItemPricedIndividually( $bundled_item_id ) |
Assert item priced individually |
assertBundledItemDiscount( $discount, $bundled_item_id ) |
Assert item discount percentage |
assertBundledItemTitle( $title, $bundled_item_id ) |
Assert custom title |
assertBundledItemVisibility( $context, $expected, $bundled_item_id ) |
Assert visibility in context |
Complete Test Example
Important Notes
⚠️ Database Tables
Product Bundles uses custom database tables:
wp_woocommerce_bundled_itemswp_woocommerce_bundled_itemmeta
The framework automatically ensures these tables exist during test setup.
⚠️ Cleanup
The base test case automatically cleans up:
- All bundled items created with
add_bundled_item() - All bundle products created with
create_bundle()
Manual cleanup is NOT required in most cases.
⚠️ Stock Sync
After adding/modifying bundled items, you may need to re-read the bundle to get synced data:
Realistic Test Data
Use production-like data for better maintainability:
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request with tests
License
MIT License - See LICENSE file for details.