Add cleanup methods to wooCommerce data factories
[MAILPOET-1936]
This commit is contained in:
committed by
M. Shull
parent
90c0e8d33b
commit
1175d99cc7
@ -60,6 +60,20 @@ class WooCommerceCustomer {
|
|||||||
return json_decode($customer_out[0], true);
|
return json_decode($customer_out[0], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
*/
|
||||||
|
function delete($id) {
|
||||||
|
$this->tester->cliToArray("wc customer delete $id --force=1 --allow-root --user=admin");
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteAll() {
|
||||||
|
$list = $this->tester->cliToArray("wc customer list --format=json --allow-root --user=admin --fields=id");
|
||||||
|
foreach (json_decode($list[0], true) as $item) {
|
||||||
|
$this->delete($item['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function update($item, $value) {
|
private function update($item, $value) {
|
||||||
$data = $this->data;
|
$data = $this->data;
|
||||||
$data[$item] = $value;
|
$data[$item] = $value;
|
||||||
|
@ -85,6 +85,20 @@ class WooCommerceOrder {
|
|||||||
return json_decode($order_out[0], true);
|
return json_decode($order_out[0], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
*/
|
||||||
|
function delete($id) {
|
||||||
|
$this->tester->cliToArray("wc shop_order delete $id --force=1 --allow-root --user=admin");
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteAll() {
|
||||||
|
$list = $this->tester->cliToArray("wc shop_order list --format=json --allow-root --user=admin --fields=id");
|
||||||
|
foreach (json_decode($list[0], true) as $item) {
|
||||||
|
$this->delete($item['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function update($update_data) {
|
private function update($update_data) {
|
||||||
$data = $this->data;
|
$data = $this->data;
|
||||||
foreach ($update_data as $item => $value) {
|
foreach ($update_data as $item => $value) {
|
||||||
|
@ -64,6 +64,20 @@ class WooCommerceProduct {
|
|||||||
return json_decode($product_out[0], true);
|
return json_decode($product_out[0], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
*/
|
||||||
|
function delete($id) {
|
||||||
|
$this->tester->cliToArray("wc product delete $id --force=1 --allow-root --user=admin");
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteAll() {
|
||||||
|
$list = $this->tester->cliToArray("wc product list --format=json --allow-root --user=admin --fields=id");
|
||||||
|
foreach (json_decode($list[0], true) as $item) {
|
||||||
|
$this->delete($item['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function update($item, $value) {
|
private function update($item, $value) {
|
||||||
$data = $this->data;
|
$data = $this->data;
|
||||||
$data[$item] = $value;
|
$data[$item] = $value;
|
||||||
|
Reference in New Issue
Block a user