Unregister all channels on test tear down

This commit is contained in:
Nima 2022-12-28 21:05:27 +00:00
parent 130b2a94c6
commit 4d6ef8ece3
2 changed files with 26 additions and 10 deletions

View File

@ -26,6 +26,11 @@ class MarketingCampaignsTest extends WC_REST_Unit_Test_Case {
*/
const ENDPOINT = '/wc-admin/marketing/campaigns';
/**
* @var MarketingChannelsService
*/
private $marketing_channels_service;
/**
* Set up.
*/
@ -40,14 +45,17 @@ class MarketingCampaignsTest extends WC_REST_Unit_Test_Case {
);
wp_set_current_user( $this->user );
/**
* MarketingChannels class.
*
* @var MarketingChannelsService $marketing_channels_service
*/
$this->marketing_channels_service = wc_get_container()->get( MarketingChannelsService::class );
}
/**
* Test teardown.
*/
public function tearDown(): void {
$this->marketing_channels_service->unregister_all();
parent::tearDown();
}
/**
* Tests that the marketing campaigns for all registered channels are aggregated and returned by the endpoint.
*/

View File

@ -25,6 +25,11 @@ class MarketingChannelsTest extends WC_REST_Unit_Test_Case {
*/
const ENDPOINT = '/wc-admin/marketing/channels';
/**
* @var MarketingChannelsService
*/
private $marketing_channels_service;
/**
* Set up.
*/
@ -39,14 +44,17 @@ class MarketingChannelsTest extends WC_REST_Unit_Test_Case {
);
wp_set_current_user( $this->user );
/**
* MarketingChannels class.
*
* @var MarketingChannelsService $marketing_channels_service
*/
$this->marketing_channels_service = wc_get_container()->get( MarketingChannelsService::class );
}
/**
* Test teardown.
*/
public function tearDown(): void {
$this->marketing_channels_service->unregister_all();
parent::tearDown();
}
/**
* Tests that the registered marketing channels are returned by the endpoint.
*/