Skip to content

Commit

Permalink
Merge pull request #104 from kschroeder/master
Browse files Browse the repository at this point in the history
Added check payment method
  • Loading branch information
kschroeder authored Aug 2, 2017
2 parents cdf5e4c + 20b7195 commit 5833cb7
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 10 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
4 changes: 2 additions & 2 deletions lib/Magento/Actions/Admin/Configuration/Enabler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -92,4 +92,4 @@ public function disable($setting, $save = true)

}

}
}
4 changes: 4 additions & 0 deletions lib/Magento/Actions/Admin/Login/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
46 changes: 46 additions & 0 deletions lib/Magento/Actions/Checkout/PaymentMethods/CheckMoneyOrder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Magium\Magento\Actions\Checkout\PaymentMethods;

use Magium\Magento\AbstractMagentoTestCase;
use Magium\WebDriver\WebDriver;

class CheckMoneyOrder implements PaymentMethodInterface
{

const ACTION = 'Checkout\PaymentMethods\CheckMoneyOrder';

protected $webDriver;
protected $testCase;

public function __construct(
WebDriver $webDriver,
AbstractMagentoTestCase $testCase
) {
$this->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());
}
}
}
4 changes: 2 additions & 2 deletions lib/Magento/Navigators/Admin/SystemConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"');
}
Expand All @@ -57,4 +57,4 @@ public function navigateTo($path)
}
}

}
}
3 changes: 2 additions & 1 deletion lib/Magento/Themes/Customer/AbstractThemeConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
32 changes: 32 additions & 0 deletions tests/Magento/Checkout/CheckMoneyOrderPaymentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Tests\Magium\Magento\Checkout;

use Magium\Magento\AbstractMagentoTestCase;
use Magium\Magento\Actions\Admin\Configuration\Enabler;
use Magium\Magento\Actions\Admin\Login\Login;
use Magium\Magento\Actions\Cart\AddItemToCart;
use Magium\Magento\Actions\Checkout\GuestCheckout;

class CheckMoneyOrderPaymentTest extends AbstractMagentoTestCase
{

public function testCheckMoneyOrder()
{
$this->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();
}

}
4 changes: 2 additions & 2 deletions tests/Magento/Checkout/SavedCCPaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

}
}
7 changes: 6 additions & 1 deletion tests/Magento18/Checkout/CustomerCheckoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ protected function setUp()
$this->switchThemeConfiguration('Magium\Magento\Themes\Magento18\ThemeConfiguration');
}

}
public function testCheckoutwithDifferentBillingAddress()
{
return parent::testCheckoutwithDifferentBillingAddress();
}

}
4 changes: 2 additions & 2 deletions tests/Magento18/Checkout/SavedCCPaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit 5833cb7

Please sign in to comment.