You've already forked wc-composable-product
- 57 unit tests covering ProductType, StockManager, CartHandler, Plugin, Admin/ProductData, Admin/Settings using Brain Monkey + Mockery - WooCommerce class stubs for testing without WP installation - PHP lint and test jobs in release workflow (test gate blocks release) - PSR-4 namespace change: WC_Composable_Product -> Magdev\WcComposableProduct - PascalCase filenames for all classes under includes/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
89 lines
1.7 KiB
PHP
89 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Minimal WC_Product stub for unit testing.
|
|
*/
|
|
class WC_Product extends WC_Data {
|
|
protected $supports = [];
|
|
protected $data = [
|
|
'name' => '',
|
|
'price' => '',
|
|
'regular_price' => '',
|
|
'status' => 'publish',
|
|
];
|
|
|
|
public function get_type() {
|
|
return 'simple';
|
|
}
|
|
|
|
public function get_name($context = 'view') {
|
|
return $this->data['name'] ?? '';
|
|
}
|
|
|
|
public function get_price($context = 'view') {
|
|
return $this->data['price'] ?? '';
|
|
}
|
|
|
|
public function get_regular_price($context = 'view') {
|
|
return $this->data['regular_price'] ?? '';
|
|
}
|
|
|
|
public function get_price_html() {
|
|
return '';
|
|
}
|
|
|
|
public function get_permalink() {
|
|
return '';
|
|
}
|
|
|
|
public function get_image_id($context = 'view') {
|
|
return 0;
|
|
}
|
|
|
|
public function get_stock_quantity($context = 'view') {
|
|
return null;
|
|
}
|
|
|
|
public function get_stock_status($context = 'view') {
|
|
return 'instock';
|
|
}
|
|
|
|
public function get_children() {
|
|
return [];
|
|
}
|
|
|
|
public function is_type($type) {
|
|
return $this->get_type() === $type;
|
|
}
|
|
|
|
public function is_purchasable() {
|
|
return true;
|
|
}
|
|
|
|
public function is_in_stock() {
|
|
return true;
|
|
}
|
|
|
|
public function managing_stock() {
|
|
return false;
|
|
}
|
|
|
|
public function backorders_allowed() {
|
|
return false;
|
|
}
|
|
|
|
public function is_sold_individually() {
|
|
return false;
|
|
}
|
|
|
|
public function set_price($price) {
|
|
$this->data['price'] = $price;
|
|
}
|
|
|
|
public function set_stock_quantity($quantity) {
|
|
}
|
|
|
|
public function supports($feature) {
|
|
return in_array($feature, $this->supports, true);
|
|
}
|
|
}
|