Revert "Revert "Fix failing tests because of un-registered product post type""

This reverts commit fbcfa6db82.
This commit is contained in:
Sam
2022-04-12 18:22:50 +02:00
committed by Veljko V
parent 7631042f3d
commit fc7313d44b
2 changed files with 9 additions and 0 deletions

View File

@@ -78,6 +78,8 @@ class AbandonedCartContentTest extends \MailPoetTest {
$this->wp->wpDeletePost((int)$product->ID); $this->wp->wpDeletePost((int)$product->ID);
} }
register_post_type("product", ['public' => true]);
$this->productIds = []; $this->productIds = [];
$this->productIds[] = $this->createPost('Product 1', '2020-05-01 01:01:01', 'product'); $this->productIds[] = $this->createPost('Product 1', '2020-05-01 01:01:01', 'product');
$this->productIds[] = $this->createPost('Product 2', '2020-06-01 01:01:01', 'product'); $this->productIds[] = $this->createPost('Product 2', '2020-06-01 01:01:01', 'product');

View File

@@ -137,6 +137,7 @@ abstract class MailPoetTest extends \Codeception\TestCase\Test { // phpcs:ignore
$this->entityManager->clear(); $this->entityManager->clear();
$this->restoreGlobals(); $this->restoreGlobals();
wp_set_current_user(0); wp_set_current_user(0);
$this->cleanUpCustomEntities();
parent::tearDown(); parent::tearDown();
} }
@@ -202,6 +203,12 @@ abstract class MailPoetTest extends \Codeception\TestCase\Test { // phpcs:ignore
} }
} }
} }
protected function cleanUpCustomEntities() {
if (post_type_exists('product')) {
unregister_post_type('product');
}
}
} }
function asCallable($fn) { function asCallable($fn) {