From ff36833270a8d65b4e2ecbe837662199f9af5374 Mon Sep 17 00:00:00 2001 From: Alexey Stoletniy Date: Thu, 23 Mar 2017 15:27:15 +0300 Subject: [PATCH] Add a hook for reinstalling Premium [PREMIUM-2] --- lib/API/Endpoints/Setup.php | 3 +++ tests/unit/API/Endpoints/SetupTest.php | 9 ++++++++- tests/unit/Newsletter/Links/LinksTest.php | 6 +++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/API/Endpoints/Setup.php b/lib/API/Endpoints/Setup.php index 21f0de7c2b..1db284137f 100644 --- a/lib/API/Endpoints/Setup.php +++ b/lib/API/Endpoints/Setup.php @@ -1,7 +1,9 @@ deactivate(); $activator->activate(); + Hooks::doAction('mailpoet_setup_reset'); return $this->successResponse(); } catch(\Exception $e) { return $this->errorResponse(array( diff --git a/tests/unit/API/Endpoints/SetupTest.php b/tests/unit/API/Endpoints/SetupTest.php index f1c4e24a3b..069326a075 100644 --- a/tests/unit/API/Endpoints/SetupTest.php +++ b/tests/unit/API/Endpoints/SetupTest.php @@ -1,4 +1,5 @@ reset(); expect($response->status)->equals(APIResponse::STATUS_OK); $signup_confirmation = Setting::getValue('signup_confirmation.enabled'); expect($signup_confirmation)->true(); + + $hook_name = 'mailpoet_setup_reset'; + expect(WPHooksHelper::isActionDone($hook_name))->true(); } function _after() { + WPHooksHelper::releaseAllHooks(); Setting::deleteMany(); } -} \ No newline at end of file +} diff --git a/tests/unit/Newsletter/Links/LinksTest.php b/tests/unit/Newsletter/Links/LinksTest.php index f1bc437122..607a48c38d 100644 --- a/tests/unit/Newsletter/Links/LinksTest.php +++ b/tests/unit/Newsletter/Links/LinksTest.php @@ -63,8 +63,8 @@ class LinksTest extends MailPoetTest { list($updated_content, $replaced_links) = Links::replace($template, $extracted_links, $processed_links); - // 1 links was replaced - expect(count($replaced_links))->equals(1); + expect($extracted_links)->count(2); + expect($replaced_links)->count(1); // links in returned content were replaced with hashes expect($updated_content) ->contains('replace by this'); @@ -200,4 +200,4 @@ class LinksTest extends MailPoetTest { ORM::raw_execute('TRUNCATE ' . SendingQueue::$_table); ORM::raw_execute('TRUNCATE ' . NewsletterLink::$_table); } -} \ No newline at end of file +}