Add cleanup methods to wooCommerce data factories

[MAILPOET-1936]
This commit is contained in:
Rostislav Wolny
2019-03-26 10:55:46 +01:00
committed by M. Shull
parent 90c0e8d33b
commit 1175d99cc7
3 changed files with 42 additions and 0 deletions

View File

@ -60,6 +60,20 @@ class WooCommerceCustomer {
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) {
$data = $this->data;
$data[$item] = $value;

View File

@ -85,6 +85,20 @@ class WooCommerceOrder {
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) {
$data = $this->data;
foreach ($update_data as $item => $value) {

View File

@ -64,6 +64,20 @@ class WooCommerceProduct {
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) {
$data = $this->data;
$data[$item] = $value;