From 7039e76c307963edf62318f205d2e79d931cc0c0 Mon Sep 17 00:00:00 2001 From: Kevin Schroeder Date: Fri, 14 Apr 2017 11:23:38 -0500 Subject: [PATCH 1/8] updated composer.json --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 62dc481..6b49ae0 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,9 @@ "magium/magium": "~1.1", "zendframework/zend-uri": "^2.5" }, + "require-dev": { + "phpunit/phpunit": "^5.7" + }, "repositories" : [ { "type" : "composer", "url" : "https://packagist.org/" From 4c5b3ed0d136c0ef6a324ddc7f15423721faa267 Mon Sep 17 00:00:00 2001 From: Kevin Schroeder Date: Tue, 18 Apr 2017 13:30:18 -0500 Subject: [PATCH 2/8] Fixed an issue where an invalid theme class was passed to the extractor --- lib/Magento/Themes/Customer/AbstractThemeConfiguration.php | 3 ++- tests/Magento18/Checkout/CustomerCheckoutTest.php | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Magento/Themes/Customer/AbstractThemeConfiguration.php b/lib/Magento/Themes/Customer/AbstractThemeConfiguration.php index ae2142b..236113f 100644 --- a/lib/Magento/Themes/Customer/AbstractThemeConfiguration.php +++ b/lib/Magento/Themes/Customer/AbstractThemeConfiguration.php @@ -4,8 +4,9 @@ use Magium\AbstractConfigurableElement; +use Magium\Themes\ThemeConfigurationInterface; -abstract class AbstractThemeConfiguration extends AbstractConfigurableElement +abstract class AbstractThemeConfiguration extends AbstractConfigurableElement implements ThemeConfigurationInterface { public $accountNavigationXpath; diff --git a/tests/Magento18/Checkout/CustomerCheckoutTest.php b/tests/Magento18/Checkout/CustomerCheckoutTest.php index bdb063c..8d19581 100644 --- a/tests/Magento18/Checkout/CustomerCheckoutTest.php +++ b/tests/Magento18/Checkout/CustomerCheckoutTest.php @@ -12,4 +12,9 @@ protected function setUp() $this->switchThemeConfiguration('Magium\Magento\Themes\Magento18\ThemeConfiguration'); } -} \ No newline at end of file + public function testCheckoutwithDifferentBillingAddress() + { + return parent::testCheckoutwithDifferentBillingAddress(); + } + +} From 5f2445be4079393af1318251fc6677234848b8d7 Mon Sep 17 00:00:00 2001 From: Kevin Schroeder Date: Tue, 18 Apr 2017 14:17:59 -0500 Subject: [PATCH 3/8] Changed the login to test for the dashboard when it navigates to the admin URL. Also changed one of the tests to change the admin URL to include /index.php --- lib/Magento/Actions/Admin/Login/Login.php | 4 ++++ tests/Magento18/Checkout/SavedCCPaymentTest.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Magento/Actions/Admin/Login/Login.php b/lib/Magento/Actions/Admin/Login/Login.php index f4d5ad0..745da15 100644 --- a/lib/Magento/Actions/Admin/Login/Login.php +++ b/lib/Magento/Actions/Admin/Login/Login.php @@ -56,6 +56,10 @@ public function login($username = null, $password = null) } } else { $this->openCommand->open($adminUrl); + $title = $this->webdriver->getTitle(); + if (strpos($title, $this->testCase->getTranslator()->translate('Dashboard')) !== false) { + return; + } } $usernameElement = $this->webdriver->byXpath($this->theme->getLoginUsernameField()); diff --git a/tests/Magento18/Checkout/SavedCCPaymentTest.php b/tests/Magento18/Checkout/SavedCCPaymentTest.php index cf99af0..c2fbfec 100644 --- a/tests/Magento18/Checkout/SavedCCPaymentTest.php +++ b/tests/Magento18/Checkout/SavedCCPaymentTest.php @@ -20,8 +20,8 @@ protected function setUp() \Magium\Magento\Themes\Admin\ThemeConfiguration::THEME )->set( 'baseUrl', - $this->getTheme(ThemeConfiguration::THEME)->getBaseUrl() . 'admin/' + $this->getTheme(ThemeConfiguration::THEME)->getBaseUrl() . 'index.php/admin/' ); $this->switchThemeConfiguration(ThemeConfiguration::THEME); } -} \ No newline at end of file +} From fb68a56a26c999d2b9f4d3e78e87a97266d73826 Mon Sep 17 00:00:00 2001 From: Kevin Schroeder Date: Wed, 2 Aug 2017 15:41:49 -0500 Subject: [PATCH 4/8] Added check / money order --- .../Actions/Admin/Configuration/Enabler.php | 4 +- .../PaymentMethods/CheckMoneyOrder.php | 46 +++++++++++++++++++ .../Navigators/Admin/SystemConfiguration.php | 4 +- .../Checkout/CheckMoneyOrderPaymentTest.php | 32 +++++++++++++ tests/Magento/Checkout/SavedCCPaymentTest.php | 4 +- 5 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 lib/Magento/Actions/Checkout/PaymentMethods/CheckMoneyOrder.php create mode 100644 tests/Magento/Checkout/CheckMoneyOrderPaymentTest.php diff --git a/lib/Magento/Actions/Admin/Configuration/Enabler.php b/lib/Magento/Actions/Admin/Configuration/Enabler.php index e03616e..4b88a3b 100644 --- a/lib/Magento/Actions/Admin/Configuration/Enabler.php +++ b/lib/Magento/Actions/Admin/Configuration/Enabler.php @@ -41,7 +41,7 @@ public function __construct( protected function setting($setting) { - $parts = explode('/', $setting); + $parts = explode('/', $setting, 2); $this->testCase->assertCount(2, $parts); $this->tab = $parts[0]; $this->section = $parts[1]; @@ -92,4 +92,4 @@ public function disable($setting, $save = true) } -} \ No newline at end of file +} diff --git a/lib/Magento/Actions/Checkout/PaymentMethods/CheckMoneyOrder.php b/lib/Magento/Actions/Checkout/PaymentMethods/CheckMoneyOrder.php new file mode 100644 index 0000000..59146a9 --- /dev/null +++ b/lib/Magento/Actions/Checkout/PaymentMethods/CheckMoneyOrder.php @@ -0,0 +1,46 @@ +webDriver = $webDriver; + $this->testCase = $testCase; + } + + public function getId() + { + return 'p_method_checkmo'; + } + + /** + * Fills in the payment form, selecting it, if necessary + * + * @param $requirePayment + */ + + public function pay($requirePayment) + { + if ($requirePayment) { + $this->testCase->assertElementExists($this->getId()); + } + + if ($this->webDriver->elementDisplayed($this->getId())) { + $element = $this->webDriver->byId($this->getId()); + $this->webDriver->getMouse()->click($element->getCoordinates()); + } + } +} diff --git a/lib/Magento/Navigators/Admin/SystemConfiguration.php b/lib/Magento/Navigators/Admin/SystemConfiguration.php index 37756fb..927587a 100644 --- a/lib/Magento/Navigators/Admin/SystemConfiguration.php +++ b/lib/Magento/Navigators/Admin/SystemConfiguration.php @@ -34,7 +34,7 @@ public function __construct( public function navigateTo($path) { - $instructions = explode('/', $path); + $instructions = explode('/', $path, 2); if (count($instructions) !== 2) { throw new InvalidInstructionException('System Configuration instructions need to be in the format of "Tab/Section"'); } @@ -57,4 +57,4 @@ public function navigateTo($path) } } -} \ No newline at end of file +} diff --git a/tests/Magento/Checkout/CheckMoneyOrderPaymentTest.php b/tests/Magento/Checkout/CheckMoneyOrderPaymentTest.php new file mode 100644 index 0000000..d6edbcb --- /dev/null +++ b/tests/Magento/Checkout/CheckMoneyOrderPaymentTest.php @@ -0,0 +1,32 @@ +getAction(Login::ACTION)->login(); + $this->getAction(Enabler::ACTION)->enable('Payment Methods/Check / Money Order'); + + $this->commandOpen($this->getTheme()->getBaseUrl()); + $this->getAction(AddItemToCart::ACTION)->addSimpleProductToCartFromCategoryPage(); + $this->setPaymentMethod('CheckMoneyOrder'); + $this->getAction(GuestCheckout::ACTION)->execute(); + } + + protected function tearDown() + { + $this->getAction(Login::ACTION)->login(); + $this->getAction(Enabler::ACTION)->disable('Payment Methods/Check / Money Order'); + parent::tearDown(); + } + +} diff --git a/tests/Magento/Checkout/SavedCCPaymentTest.php b/tests/Magento/Checkout/SavedCCPaymentTest.php index 8ed7a1f..b63ed8b 100644 --- a/tests/Magento/Checkout/SavedCCPaymentTest.php +++ b/tests/Magento/Checkout/SavedCCPaymentTest.php @@ -26,7 +26,7 @@ protected function tearDown() { $this->getAction(Login::ACTION)->login(); $this->getAction(Enabler::ACTION)->disable('Payment Methods/Saved CC'); - parent::tearDown(); // TODO: Change the autogenerated stub + parent::tearDown(); } -} \ No newline at end of file +} From 656843b184fd1d792d9813b74b602967e722beb1 Mon Sep 17 00:00:00 2001 From: Kevin Schroeder Date: Fri, 14 Apr 2017 11:23:38 -0500 Subject: [PATCH 5/8] updated composer.json --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 62dc481..6b49ae0 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,9 @@ "magium/magium": "~1.1", "zendframework/zend-uri": "^2.5" }, + "require-dev": { + "phpunit/phpunit": "^5.7" + }, "repositories" : [ { "type" : "composer", "url" : "https://packagist.org/" From 054f112b25106111390aac84f8a16096ae93a416 Mon Sep 17 00:00:00 2001 From: Kevin Schroeder Date: Tue, 18 Apr 2017 13:30:18 -0500 Subject: [PATCH 6/8] Fixed an issue where an invalid theme class was passed to the extractor --- lib/Magento/Themes/Customer/AbstractThemeConfiguration.php | 3 ++- tests/Magento18/Checkout/CustomerCheckoutTest.php | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Magento/Themes/Customer/AbstractThemeConfiguration.php b/lib/Magento/Themes/Customer/AbstractThemeConfiguration.php index ae2142b..236113f 100644 --- a/lib/Magento/Themes/Customer/AbstractThemeConfiguration.php +++ b/lib/Magento/Themes/Customer/AbstractThemeConfiguration.php @@ -4,8 +4,9 @@ use Magium\AbstractConfigurableElement; +use Magium\Themes\ThemeConfigurationInterface; -abstract class AbstractThemeConfiguration extends AbstractConfigurableElement +abstract class AbstractThemeConfiguration extends AbstractConfigurableElement implements ThemeConfigurationInterface { public $accountNavigationXpath; diff --git a/tests/Magento18/Checkout/CustomerCheckoutTest.php b/tests/Magento18/Checkout/CustomerCheckoutTest.php index bdb063c..8d19581 100644 --- a/tests/Magento18/Checkout/CustomerCheckoutTest.php +++ b/tests/Magento18/Checkout/CustomerCheckoutTest.php @@ -12,4 +12,9 @@ protected function setUp() $this->switchThemeConfiguration('Magium\Magento\Themes\Magento18\ThemeConfiguration'); } -} \ No newline at end of file + public function testCheckoutwithDifferentBillingAddress() + { + return parent::testCheckoutwithDifferentBillingAddress(); + } + +} From 84a94b583ea90b90a2b3b7dda891e2a6604cddd4 Mon Sep 17 00:00:00 2001 From: Kevin Schroeder Date: Tue, 18 Apr 2017 14:17:59 -0500 Subject: [PATCH 7/8] Changed the login to test for the dashboard when it navigates to the admin URL. Also changed one of the tests to change the admin URL to include /index.php --- lib/Magento/Actions/Admin/Login/Login.php | 4 ++++ tests/Magento18/Checkout/SavedCCPaymentTest.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Magento/Actions/Admin/Login/Login.php b/lib/Magento/Actions/Admin/Login/Login.php index f4d5ad0..745da15 100644 --- a/lib/Magento/Actions/Admin/Login/Login.php +++ b/lib/Magento/Actions/Admin/Login/Login.php @@ -56,6 +56,10 @@ public function login($username = null, $password = null) } } else { $this->openCommand->open($adminUrl); + $title = $this->webdriver->getTitle(); + if (strpos($title, $this->testCase->getTranslator()->translate('Dashboard')) !== false) { + return; + } } $usernameElement = $this->webdriver->byXpath($this->theme->getLoginUsernameField()); diff --git a/tests/Magento18/Checkout/SavedCCPaymentTest.php b/tests/Magento18/Checkout/SavedCCPaymentTest.php index cf99af0..c2fbfec 100644 --- a/tests/Magento18/Checkout/SavedCCPaymentTest.php +++ b/tests/Magento18/Checkout/SavedCCPaymentTest.php @@ -20,8 +20,8 @@ protected function setUp() \Magium\Magento\Themes\Admin\ThemeConfiguration::THEME )->set( 'baseUrl', - $this->getTheme(ThemeConfiguration::THEME)->getBaseUrl() . 'admin/' + $this->getTheme(ThemeConfiguration::THEME)->getBaseUrl() . 'index.php/admin/' ); $this->switchThemeConfiguration(ThemeConfiguration::THEME); } -} \ No newline at end of file +} From 3017d17bc39a1ac20cb94748f2b2007a7f6a776c Mon Sep 17 00:00:00 2001 From: Kevin Schroeder Date: Wed, 2 Aug 2017 15:41:49 -0500 Subject: [PATCH 8/8] Added check / money order --- .../Actions/Admin/Configuration/Enabler.php | 4 +- .../PaymentMethods/CheckMoneyOrder.php | 46 +++++++++++++++++++ .../Navigators/Admin/SystemConfiguration.php | 4 +- .../Checkout/CheckMoneyOrderPaymentTest.php | 32 +++++++++++++ tests/Magento/Checkout/SavedCCPaymentTest.php | 4 +- 5 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 lib/Magento/Actions/Checkout/PaymentMethods/CheckMoneyOrder.php create mode 100644 tests/Magento/Checkout/CheckMoneyOrderPaymentTest.php diff --git a/lib/Magento/Actions/Admin/Configuration/Enabler.php b/lib/Magento/Actions/Admin/Configuration/Enabler.php index e03616e..4b88a3b 100644 --- a/lib/Magento/Actions/Admin/Configuration/Enabler.php +++ b/lib/Magento/Actions/Admin/Configuration/Enabler.php @@ -41,7 +41,7 @@ public function __construct( protected function setting($setting) { - $parts = explode('/', $setting); + $parts = explode('/', $setting, 2); $this->testCase->assertCount(2, $parts); $this->tab = $parts[0]; $this->section = $parts[1]; @@ -92,4 +92,4 @@ public function disable($setting, $save = true) } -} \ No newline at end of file +} diff --git a/lib/Magento/Actions/Checkout/PaymentMethods/CheckMoneyOrder.php b/lib/Magento/Actions/Checkout/PaymentMethods/CheckMoneyOrder.php new file mode 100644 index 0000000..59146a9 --- /dev/null +++ b/lib/Magento/Actions/Checkout/PaymentMethods/CheckMoneyOrder.php @@ -0,0 +1,46 @@ +webDriver = $webDriver; + $this->testCase = $testCase; + } + + public function getId() + { + return 'p_method_checkmo'; + } + + /** + * Fills in the payment form, selecting it, if necessary + * + * @param $requirePayment + */ + + public function pay($requirePayment) + { + if ($requirePayment) { + $this->testCase->assertElementExists($this->getId()); + } + + if ($this->webDriver->elementDisplayed($this->getId())) { + $element = $this->webDriver->byId($this->getId()); + $this->webDriver->getMouse()->click($element->getCoordinates()); + } + } +} diff --git a/lib/Magento/Navigators/Admin/SystemConfiguration.php b/lib/Magento/Navigators/Admin/SystemConfiguration.php index 37756fb..927587a 100644 --- a/lib/Magento/Navigators/Admin/SystemConfiguration.php +++ b/lib/Magento/Navigators/Admin/SystemConfiguration.php @@ -34,7 +34,7 @@ public function __construct( public function navigateTo($path) { - $instructions = explode('/', $path); + $instructions = explode('/', $path, 2); if (count($instructions) !== 2) { throw new InvalidInstructionException('System Configuration instructions need to be in the format of "Tab/Section"'); } @@ -57,4 +57,4 @@ public function navigateTo($path) } } -} \ No newline at end of file +} diff --git a/tests/Magento/Checkout/CheckMoneyOrderPaymentTest.php b/tests/Magento/Checkout/CheckMoneyOrderPaymentTest.php new file mode 100644 index 0000000..d6edbcb --- /dev/null +++ b/tests/Magento/Checkout/CheckMoneyOrderPaymentTest.php @@ -0,0 +1,32 @@ +getAction(Login::ACTION)->login(); + $this->getAction(Enabler::ACTION)->enable('Payment Methods/Check / Money Order'); + + $this->commandOpen($this->getTheme()->getBaseUrl()); + $this->getAction(AddItemToCart::ACTION)->addSimpleProductToCartFromCategoryPage(); + $this->setPaymentMethod('CheckMoneyOrder'); + $this->getAction(GuestCheckout::ACTION)->execute(); + } + + protected function tearDown() + { + $this->getAction(Login::ACTION)->login(); + $this->getAction(Enabler::ACTION)->disable('Payment Methods/Check / Money Order'); + parent::tearDown(); + } + +} diff --git a/tests/Magento/Checkout/SavedCCPaymentTest.php b/tests/Magento/Checkout/SavedCCPaymentTest.php index 8ed7a1f..b63ed8b 100644 --- a/tests/Magento/Checkout/SavedCCPaymentTest.php +++ b/tests/Magento/Checkout/SavedCCPaymentTest.php @@ -26,7 +26,7 @@ protected function tearDown() { $this->getAction(Login::ACTION)->login(); $this->getAction(Enabler::ACTION)->disable('Payment Methods/Saved CC'); - parent::tearDown(); // TODO: Change the autogenerated stub + parent::tearDown(); } -} \ No newline at end of file +}