From 0d97a49e304a284c6cd5cdd9ab03cf485b697908 Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Mon, 21 Oct 2019 13:13:11 +0200 Subject: [PATCH 01/18] cache wordpress --- CHANGELOG.md | 4 ++ .../Tests/Acceptance/WpdeskTracker.php | 50 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php diff --git a/CHANGELOG.md b/CHANGELOG.md index fb749c1..de355b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +[1.2.7] - 2019-10-21 +# Added +* tracker tests class WpdeskTracker + [1.2.6] - 2019-09-13 # Added * can fill custom fields diff --git a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php new file mode 100644 index 0000000..1bb0ccb --- /dev/null +++ b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php @@ -0,0 +1,50 @@ +<?php + +namespace WPDesk\Codeception\Tests\Acceptance; + +use AcceptanceTester; + +class WpdeskTracker extends Cest +{ + + /** + * Is deactivation with tracker questions? + * + * @var bool + */ + protected $is_activation_with_tracker_questions = false; + + /** + * Plugin deactivation. + * + * @param AcceptanceTester $i . + * + * @throws \Codeception\Exception\ModuleException . + */ + public function pluginDeactivation($i) + { + $i->loginAsAdmin(); + + $i->amOnPluginsPage(); + $i->seePluginActivated($this->getPluginSlug()); + + $i->deactivatePlugin($this->getPluginSlug()); + + if ($this->is_activation_with_tracker_questions) { + $i->see($this->getDeactivatingMessage()); + } else { + $i->dontSee($this->getDeactivatingMessage()); + } + } + + /** + * Get deactivation message. + * + * @return string + */ + protected function getDeactivatingMessage() + { + return sprintf('You are deactivating %1$s plugin.', $this->getPluginTitle()); + } + +} -- GitLab From 18d6fbfdb5cb986adc9dc66366363d7e0b044abc Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Mon, 21 Oct 2019 13:21:42 +0200 Subject: [PATCH 02/18] cache wordpress --- src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php index 1bb0ccb..cd0e56b 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php @@ -32,6 +32,8 @@ class WpdeskTracker extends Cest if ($this->is_activation_with_tracker_questions) { $i->see($this->getDeactivatingMessage()); + $i->click('Skip & Deactivate'); + $i->seePluginDeactivated($this->getPluginSlug()); } else { $i->dontSee($this->getDeactivatingMessage()); } -- GitLab From 9d1ba82cae7dee1e7ae15caceab088120c2cc6ce Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Mon, 21 Oct 2019 13:52:41 +0200 Subject: [PATCH 03/18] cache wordpress --- src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php index cd0e56b..4479dc2 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php @@ -28,7 +28,7 @@ class WpdeskTracker extends Cest $i->amOnPluginsPage(); $i->seePluginActivated($this->getPluginSlug()); - $i->deactivatePlugin($this->getPluginSlug()); + $i->click('Deactivate', '//tr[@data-plugin equals "' . $this->getPluginSlug() . '"]'); if ($this->is_activation_with_tracker_questions) { $i->see($this->getDeactivatingMessage()); -- GitLab From f34832bce6762a3f6570e5345fc18e4793fe804d Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Mon, 21 Oct 2019 14:02:08 +0200 Subject: [PATCH 04/18] cache wordpress --- src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php index 4479dc2..91f5188 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php @@ -28,7 +28,7 @@ class WpdeskTracker extends Cest $i->amOnPluginsPage(); $i->seePluginActivated($this->getPluginSlug()); - $i->click('Deactivate', '//tr[@data-plugin equals "' . $this->getPluginSlug() . '"]'); + $i->click('Deactivate', '//tr[@data-slug="' . $this->getPluginSlug() . '"]'); if ($this->is_activation_with_tracker_questions) { $i->see($this->getDeactivatingMessage()); -- GitLab From 8ae092b7aa9939c564ee1675f708a4d4334a0e1c Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Mon, 21 Oct 2019 14:02:42 +0200 Subject: [PATCH 05/18] cache wordpress --- src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php index 91f5188..e1fdb0c 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php @@ -7,6 +7,9 @@ use AcceptanceTester; class WpdeskTracker extends Cest { + const DEACTIVATE = 'Deactivate'; + const SKIP_AND_DEACTIVATE = 'Skip & Deactivate'; + /** * Is deactivation with tracker questions? * @@ -28,11 +31,11 @@ class WpdeskTracker extends Cest $i->amOnPluginsPage(); $i->seePluginActivated($this->getPluginSlug()); - $i->click('Deactivate', '//tr[@data-slug="' . $this->getPluginSlug() . '"]'); + $i->click(self::DEACTIVATE, '//tr[@data-slug="' . $this->getPluginSlug() . '"]'); if ($this->is_activation_with_tracker_questions) { $i->see($this->getDeactivatingMessage()); - $i->click('Skip & Deactivate'); + $i->click(self::SKIP_AND_DEACTIVATE); $i->seePluginDeactivated($this->getPluginSlug()); } else { $i->dontSee($this->getDeactivatingMessage()); -- GitLab From 82c334b720d84e6c7edfbbbcb679d4c799f3a271 Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Mon, 21 Oct 2019 14:03:28 +0200 Subject: [PATCH 06/18] cache wordpress --- src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php index e1fdb0c..b22d71b 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php @@ -9,6 +9,7 @@ class WpdeskTracker extends Cest const DEACTIVATE = 'Deactivate'; const SKIP_AND_DEACTIVATE = 'Skip & Deactivate'; + const YOU_ARE_DEACTIVATING_PLUGIN = 'You are deactivating %1$s plugin.'; /** * Is deactivation with tracker questions? @@ -49,7 +50,7 @@ class WpdeskTracker extends Cest */ protected function getDeactivatingMessage() { - return sprintf('You are deactivating %1$s plugin.', $this->getPluginTitle()); + return sprintf(self::YOU_ARE_DEACTIVATING_PLUGIN, $this->getPluginTitle()); } } -- GitLab From fb9904f31e087d182cc48caa47e87ef8c986619a Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Mon, 21 Oct 2019 14:04:48 +0200 Subject: [PATCH 07/18] cache wordpress --- src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php index b22d71b..7aa899b 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php @@ -10,6 +10,7 @@ class WpdeskTracker extends Cest const DEACTIVATE = 'Deactivate'; const SKIP_AND_DEACTIVATE = 'Skip & Deactivate'; const YOU_ARE_DEACTIVATING_PLUGIN = 'You are deactivating %1$s plugin.'; + const TR_DATA_SLUG = '//tr[@data-slug="%1$s"]'; /** * Is deactivation with tracker questions? @@ -32,7 +33,7 @@ class WpdeskTracker extends Cest $i->amOnPluginsPage(); $i->seePluginActivated($this->getPluginSlug()); - $i->click(self::DEACTIVATE, '//tr[@data-slug="' . $this->getPluginSlug() . '"]'); + $i->click(self::DEACTIVATE, sprintf(self::TR_DATA_SLUG, $this->getPluginSlug()); if ($this->is_activation_with_tracker_questions) { $i->see($this->getDeactivatingMessage()); -- GitLab From b7e9da713644d7ee39a27d5f5767734b52581938 Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Mon, 21 Oct 2019 14:19:29 +0200 Subject: [PATCH 08/18] cache wordpress --- src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php index 7aa899b..c6be5db 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php @@ -33,7 +33,7 @@ class WpdeskTracker extends Cest $i->amOnPluginsPage(); $i->seePluginActivated($this->getPluginSlug()); - $i->click(self::DEACTIVATE, sprintf(self::TR_DATA_SLUG, $this->getPluginSlug()); + $i->click(self::DEACTIVATE, sprintf(self::TR_DATA_SLUG, $this->getPluginSlug())); if ($this->is_activation_with_tracker_questions) { $i->see($this->getDeactivatingMessage()); -- GitLab From bbdd0529475580cd186dce240bab6730d6471ec9 Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Mon, 21 Oct 2019 15:20:43 +0200 Subject: [PATCH 09/18] Reactivate plugin after test --- .../Codeception/Tests/Acceptance/WpdeskTracker.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php index c6be5db..dd510e4 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php @@ -20,6 +20,19 @@ class WpdeskTracker extends Cest protected $is_activation_with_tracker_questions = false; /** + * Activate plugin after test. + * + * @param AcceptanceTester \$i . + * + * @throws \Codeception\Exception\ModuleException . + */ + public function _after($i) + { + $i->amOnPluginsPage(); + $i->activatePlugin($this->getPluginSlug()); + } + + /** * Plugin deactivation. * * @param AcceptanceTester $i . -- GitLab From eca9379ea2ecd53471a887f846e56ffc39e1e165 Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Mon, 21 Oct 2019 15:42:45 +0200 Subject: [PATCH 10/18] Reactivate plugin after test --- src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php index dd510e4..5b9cab2 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/WpdeskTracker.php @@ -11,6 +11,7 @@ class WpdeskTracker extends Cest const SKIP_AND_DEACTIVATE = 'Skip & Deactivate'; const YOU_ARE_DEACTIVATING_PLUGIN = 'You are deactivating %1$s plugin.'; const TR_DATA_SLUG = '//tr[@data-slug="%1$s"]'; + const H2_DEACTIVATION = '//h2[contains(text(),"%1$s")]'; /** * Is deactivation with tracker questions? @@ -49,7 +50,7 @@ class WpdeskTracker extends Cest $i->click(self::DEACTIVATE, sprintf(self::TR_DATA_SLUG, $this->getPluginSlug())); if ($this->is_activation_with_tracker_questions) { - $i->see($this->getDeactivatingMessage()); + $i->seeNumberOfElements(sprintf(self::H2_DEACTIVATION, $this->getDeactivatingMessage()), 1); $i->click(self::SKIP_AND_DEACTIVATE); $i->seePluginDeactivated($this->getPluginSlug()); } else { -- GitLab From 4c2cf8cee03681f9170625a187449b776196aa6d Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Thu, 31 Oct 2019 10:47:35 +0100 Subject: [PATCH 11/18] Activation cest --- .../Tests/Acceptance/ActivationCest.php | 26 +++++++++++++++++++ .../Codeception/Tests/Acceptance/Cest.php | 24 +++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php diff --git a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php new file mode 100644 index 0000000..d17a02a --- /dev/null +++ b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php @@ -0,0 +1,26 @@ +<?php + +namespace WPDesk\Codeception\Tests\Acceptance; + +/** + * Parent class for WPDesk acceptance tests. + * Handles plugin slug from env variable. + * + * @package WPDesk\Codeception\Tests\Acceptance + */ +abstract class ActivationCest extends Cest +{ + + /** + * Plugin activation date in options. + * + * @param AcceptanceTester $i . + * + * @throws \Codeception\Exception\ModuleException . + */ + public function pluginActivationDateInOptions( AcceptanceTester $i ) { + $i->haveOptionInDatabase(); + } + + +} diff --git a/src/WPDesk/Codeception/Tests/Acceptance/Cest.php b/src/WPDesk/Codeception/Tests/Acceptance/Cest.php index ecc93e1..ddbb9db 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/Cest.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/Cest.php @@ -18,6 +18,13 @@ abstract class Cest */ protected $pluginSlug = ''; + /** + * Plugin file. + * + * @var string + */ + protected $pluginFile = ''; + /** * Plugin title. * @@ -28,6 +35,7 @@ abstract class Cest public function __construct() { $this->pluginSlug = getenv('WPDESK_PLUGIN_SLUG'); + $this->pluginFile = getenv('WPDESK_PLUGIN_FILE'); $this->pluginTitle = getenv('WPDESK_PLUGIN_TITLE'); } @@ -39,6 +47,14 @@ abstract class Cest return $this->pluginSlug; } + /** + * @return string + */ + protected function getPluginFile() + { + return $this->pluginFile; + } + /** * @return string */ @@ -55,6 +71,14 @@ abstract class Cest $this->pluginSlug = $pluginSlug; } + /** + * @param string $pluginFile + */ + protected function setPluginFile($pluginFile) + { + $this->pluginFile = $pluginFile; + } + /** * @param string $pluginTitle */ -- GitLab From d92ef4a37a47c8b950718038aa42f67f500d261d Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Thu, 31 Oct 2019 10:51:18 +0100 Subject: [PATCH 12/18] Activation cest --- CHANGELOG.md | 4 ++++ scripts/bootstrap.sh | 1 + src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php | 2 +- src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php | 5 +++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de355b8..7253add 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +[1.3.0] - 2019-10-31 +# Added +* activation date option test + [1.2.7] - 2019-10-21 # Added * tracker tests class WpdeskTracker diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 1461586..e38023a 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -1,6 +1,7 @@ #!/bin/bash export WPDESK_PLUGIN_SLUG=enter-plugin-slug-here +export WPDESK_PLUGIN_FILE=enter-plugin-file-here export WPDESK_PLUGIN_TITLE="Enter plugin title here" export WOOTESTS_IP=${WOOTESTS_IP:wootests} diff --git a/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php b/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php index 18b7708..e056d51 100644 --- a/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php +++ b/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php @@ -17,7 +17,7 @@ class AcceptanceTestGenerator extends Test use WPDesk\Codeception\Tests\Acceptance\Cest; -class {{name}} extends Cest { +class {{name}} extends ActivationCest { /** * Deactivate plugins before tests. diff --git a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php index d17a02a..9e45aed 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php @@ -18,8 +18,9 @@ abstract class ActivationCest extends Cest * * @throws \Codeception\Exception\ModuleException . */ - public function pluginActivationDateInOptions( AcceptanceTester $i ) { - $i->haveOptionInDatabase(); + public function pluginActivationDateInOptions(AcceptanceTester $i) + { + $i->haveOptionInDatabase('plugin_activation_' . $this->getPluginFile()); } -- GitLab From d8f3a15da24775936b3eec30f4815e4abcf1c055 Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Thu, 31 Oct 2019 10:54:00 +0100 Subject: [PATCH 13/18] Activation cest --- src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php b/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php index e056d51..c72e480 100644 --- a/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php +++ b/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php @@ -15,9 +15,9 @@ class AcceptanceTestGenerator extends Test protected $template = <<<EOF <?php {{namespace}} -use WPDesk\Codeception\Tests\Acceptance\Cest; +use WPDesk\Codeception\Tests\Acceptance\ActivationCest as ActivationCestAlias; -class {{name}} extends ActivationCest { +class {{name}} extends ActivationCestAlias { /** * Deactivate plugins before tests. -- GitLab From df97f25ed46da912f1656cd3af0af484933924ec Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Thu, 31 Oct 2019 11:01:40 +0100 Subject: [PATCH 14/18] Activation cest --- .../Codeception/Tests/Acceptance/ActivationCest.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php index 9e45aed..57b9cb6 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php @@ -20,7 +20,15 @@ abstract class ActivationCest extends Cest */ public function pluginActivationDateInOptions(AcceptanceTester $i) { - $i->haveOptionInDatabase('plugin_activation_' . $this->getPluginFile()); + $option_name = 'plugin_activation_' . $this->getPluginFile(); + $i->loginAsAdmin(); + $i->amOnPluginsPage(); + $i->deactivatePlugin($this->getPluginSlug()); + $i->dontHaveOptionInDatabase($option_name); + $i->amOnPluginsPage(); + $i->activatePlugin($this->getPluginSlug()); + $i->amOnPluginsPage(); + $i->haveOptionInDatabase($option_name); } -- GitLab From 718428c559e1b5b649bdcdab1e8b30342dc42c9a Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Thu, 31 Oct 2019 11:14:37 +0100 Subject: [PATCH 15/18] Activation cest --- src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php | 4 ++-- src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php b/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php index c72e480..254838c 100644 --- a/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php +++ b/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php @@ -26,7 +26,7 @@ class {{name}} extends ActivationCestAlias { * * @throws \Codeception\Exception\ModuleException . */ - public function _before( AcceptanceTester \$i ) { + public function _before( \$i ) { \$i->loginAsAdmin(); \$i->amOnPluginsPage(); \$i->deactivatePlugin( \$this->getPluginSlug() ); @@ -41,7 +41,7 @@ class {{name}} extends ActivationCestAlias { * * @throws \Codeception\Exception\ModuleException . */ - public function pluginActivation( AcceptanceTester \$i ) { + public function pluginActivation( \$i ) { \$i->loginAsAdmin(); diff --git a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php index 57b9cb6..cc7e082 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php @@ -18,7 +18,7 @@ abstract class ActivationCest extends Cest * * @throws \Codeception\Exception\ModuleException . */ - public function pluginActivationDateInOptions(AcceptanceTester $i) + public function pluginActivationDateInOptions($i) { $option_name = 'plugin_activation_' . $this->getPluginFile(); $i->loginAsAdmin(); -- GitLab From 0f285e5106c7c9e901cdc3d9c2cc7b37e2b7df21 Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Thu, 31 Oct 2019 11:43:46 +0100 Subject: [PATCH 16/18] Activation cest --- src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php index cc7e082..57d4bdd 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php @@ -28,6 +28,7 @@ abstract class ActivationCest extends Cest $i->amOnPluginsPage(); $i->activatePlugin($this->getPluginSlug()); $i->amOnPluginsPage(); + $i->seePluginActivated($this->getPluginSlug()); $i->haveOptionInDatabase($option_name); } -- GitLab From d267797556c4697b08b204f2036e971214c9113a Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Thu, 31 Oct 2019 11:46:01 +0100 Subject: [PATCH 17/18] Activation cest --- src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php | 6 +++++- src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php b/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php index 254838c..44cde79 100644 --- a/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php +++ b/src/WPDesk/Codeception/Command/AcceptanceTestGenerator.php @@ -31,7 +31,11 @@ class {{name}} extends ActivationCestAlias { \$i->amOnPluginsPage(); \$i->deactivatePlugin( \$this->getPluginSlug() ); \$i->amOnPluginsPage(); - \$i->deactivatePlugin( 'woocommerce' ); + \$i->seePluginDeactivated( \$this->getPluginSlug() ); + \$i->amOnPluginsPage(); + \$i->deactivatePlugin( self::WOOCOMMERCE_PLUGIN_SLUG ); + \$i->amOnPluginsPage(); + \$i->seePluginDeactivated( self::WOOCOMMERCE_PLUGIN_SLUG ); } /** diff --git a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php index 57d4bdd..1dc4cb7 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php @@ -11,6 +11,8 @@ namespace WPDesk\Codeception\Tests\Acceptance; abstract class ActivationCest extends Cest { + const WOOCOMMERCE_PLUGIN_SLUG = 'woocommerce'; + /** * Plugin activation date in options. * @@ -30,6 +32,10 @@ abstract class ActivationCest extends Cest $i->amOnPluginsPage(); $i->seePluginActivated($this->getPluginSlug()); $i->haveOptionInDatabase($option_name); + $i->amOnPluginsPage(); + $i->activatePlugin(self::WOOCOMMERCE_PLUGIN_SLUG); + $i->amOnPluginsPage(); + $i->seePluginActivated(self::WOOCOMMERCE_PLUGIN_SLUG); } -- GitLab From d37ec36f848284e357c7869c01e249a6bb71e985 Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Thu, 31 Oct 2019 12:26:28 +0100 Subject: [PATCH 18/18] Activation cest --- .../Tests/Acceptance/ActivationCest.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php index 1dc4cb7..472d7a1 100644 --- a/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php +++ b/src/WPDesk/Codeception/Tests/Acceptance/ActivationCest.php @@ -23,19 +23,21 @@ abstract class ActivationCest extends Cest public function pluginActivationDateInOptions($i) { $option_name = 'plugin_activation_' . $this->getPluginFile(); - $i->loginAsAdmin(); + $i->dontHaveOptionInDatabase($option_name); + + $i->amOnPluginsPage(); + $i->activatePlugin(self::WOOCOMMERCE_PLUGIN_SLUG); + $i->amOnPluginsPage(); + $i->seePluginActivated(self::WOOCOMMERCE_PLUGIN_SLUG); + $i->amOnPluginsPage(); $i->deactivatePlugin($this->getPluginSlug()); - $i->dontHaveOptionInDatabase($option_name); $i->amOnPluginsPage(); $i->activatePlugin($this->getPluginSlug()); $i->amOnPluginsPage(); $i->seePluginActivated($this->getPluginSlug()); - $i->haveOptionInDatabase($option_name); - $i->amOnPluginsPage(); - $i->activatePlugin(self::WOOCOMMERCE_PLUGIN_SLUG); - $i->amOnPluginsPage(); - $i->seePluginActivated(self::WOOCOMMERCE_PLUGIN_SLUG); + + $i->seeOptionInDatabase(['option_name' => $option_name]); } -- GitLab