Skip to content

Commit

Permalink
Merge pull request #597 from magento-south/BUGS
Browse files Browse the repository at this point in the history
[South] Bug fixes & tests
  • Loading branch information
slavvka committed Sep 14, 2015
2 parents b2cbffb + b981286 commit b4128b2
Show file tree
Hide file tree
Showing 33 changed files with 1,096 additions and 405 deletions.
110 changes: 0 additions & 110 deletions app/code/Magento/Customer/Controller/Account.php

This file was deleted.

25 changes: 14 additions & 11 deletions app/code/Magento/Customer/Controller/Account/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
*/
namespace Magento\Customer\Controller\Account;

use Magento\Customer\Controller\AccountInterface;
use Magento\Customer\Model\Url;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Customer\Model\Session;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\View\Result\PageFactory;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Customer\Api\AccountManagementInterface;
use Magento\Customer\Api\CustomerRepositoryInterface;
Expand All @@ -25,7 +26,7 @@
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Confirm extends \Magento\Customer\Controller\Account
class Confirm extends Action implements AccountInterface
{
/** @var ScopeConfigInterface */
protected $scopeConfig;
Expand All @@ -45,37 +46,39 @@ class Confirm extends \Magento\Customer\Controller\Account
/** @var \Magento\Framework\UrlInterface */
protected $urlModel;

/**
* @var Session
*/
protected $session;

/**
* @param Context $context
* @param Session $customerSession
* @param PageFactory $resultPageFactory
* @param ScopeConfigInterface $scopeConfig
* @param StoreManagerInterface $storeManager
* @param AccountManagementInterface $customerAccountManagement
* @param CustomerRepositoryInterface $customerRepository
* @param Address $addressHelper
* @param UrlFactory $urlFactory
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Context $context,
Session $customerSession,
PageFactory $resultPageFactory,
ScopeConfigInterface $scopeConfig,
StoreManagerInterface $storeManager,
AccountManagementInterface $customerAccountManagement,
CustomerRepositoryInterface $customerRepository,
Address $addressHelper,
UrlFactory $urlFactory
) {
$this->session = $customerSession;
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
$this->customerAccountManagement = $customerAccountManagement;
$this->customerRepository = $customerRepository;
$this->addressHelper = $addressHelper;
$this->urlModel = $urlFactory->create();
parent::__construct($context, $customerSession, $resultPageFactory);
parent::__construct($context);
}

/**
Expand All @@ -88,7 +91,7 @@ public function execute()
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);

if ($this->_getSession()->isLoggedIn()) {
if ($this->session->isLoggedIn()) {
$resultRedirect->setPath('*/*/');
return $resultRedirect;
}
Expand All @@ -102,7 +105,7 @@ public function execute()
// log in and send greeting email
$customerEmail = $this->customerRepository->getById($customerId)->getEmail();
$customer = $this->customerAccountManagement->activate($customerEmail, $key);
$this->_getSession()->setCustomerDataAsLoggedIn($customer);
$this->session->setCustomerDataAsLoggedIn($customer);

$this->messageManager->addSuccess($this->getSuccessMessage());
$resultRedirect->setUrl($this->getSuccessRedirect());
Expand Down Expand Up @@ -158,8 +161,8 @@ protected function getSuccessRedirect()
Url::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD,
ScopeInterface::SCOPE_STORE
);
if (!$redirectToDashboard && $this->_getSession()->getBeforeAuthUrl()) {
$successUrl = $this->_getSession()->getBeforeAuthUrl(true);
if (!$redirectToDashboard && $this->session->getBeforeAuthUrl()) {
$successUrl = $this->session->getBeforeAuthUrl(true);
} else {
$successUrl = $this->urlModel->getUrl('*/*/index', ['_secure' => true]);
}
Expand Down
22 changes: 18 additions & 4 deletions app/code/Magento/Customer/Controller/Account/Confirmation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,33 @@
*/
namespace Magento\Customer\Controller\Account;

use Magento\Customer\Controller\AccountInterface;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Customer\Model\Session;
use Magento\Framework\View\Result\PageFactory;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Customer\Api\AccountManagementInterface;
use Magento\Framework\Exception\State\InvalidTransitionException;

class Confirmation extends \Magento\Customer\Controller\Account
class Confirmation extends Action implements AccountInterface
{
/** @var StoreManagerInterface */
protected $storeManager;

/** @var AccountManagementInterface */
protected $customerAccountManagement;

/**
* @var Session
*/
protected $session;

/**
* @var PageFactory
*/
protected $resultPageFactory;

/**
* @param Context $context
* @param Session $customerSession
Expand All @@ -35,9 +47,11 @@ public function __construct(
StoreManagerInterface $storeManager,
AccountManagementInterface $customerAccountManagement
) {
$this->session = $customerSession;
$this->resultPageFactory = $resultPageFactory;
$this->storeManager = $storeManager;
$this->customerAccountManagement = $customerAccountManagement;
parent::__construct($context, $customerSession, $resultPageFactory);
parent::__construct($context);
}

/**
Expand All @@ -47,7 +61,7 @@ public function __construct(
*/
public function execute()
{
if ($this->_getSession()->isLoggedIn()) {
if ($this->session->isLoggedIn()) {
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('*/*/');
Expand All @@ -73,7 +87,7 @@ public function execute()
$resultRedirect->setPath('*/*/*', ['email' => $email, '_secure' => true]);
return $resultRedirect;
}
$this->_getSession()->setUsername($email);
$this->session->setUsername($email);
$resultRedirect->setPath('*/*/index', ['_secure' => true]);
return $resultRedirect;
}
Expand Down
20 changes: 17 additions & 3 deletions app/code/Magento/Customer/Controller/Account/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,28 @@
*/
namespace Magento\Customer\Controller\Account;

use Magento\Customer\Controller\AccountInterface;
use Magento\Customer\Model\Registration;
use Magento\Customer\Model\Session;
use Magento\Framework\App\Action\Action;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Context;

class Create extends \Magento\Customer\Controller\Account
class Create extends Action implements AccountInterface
{
/** @var Registration */
protected $registration;

/**
* @var Session
*/
protected $session;

/**
* @var PageFactory
*/
protected $resultPageFactory;

/**
* @param Context $context
* @param Session $customerSession
Expand All @@ -28,8 +40,10 @@ public function __construct(
PageFactory $resultPageFactory,
Registration $registration
) {
$this->session = $customerSession;
$this->resultPageFactory = $resultPageFactory;
$this->registration = $registration;
parent::__construct($context, $customerSession, $resultPageFactory);
parent::__construct($context);
}

/**
Expand All @@ -39,7 +53,7 @@ public function __construct(
*/
public function execute()
{
if ($this->_getSession()->isLoggedIn() || !$this->registration->isAllowed()) {
if ($this->session->isLoggedIn() || !$this->registration->isAllowed()) {
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('*/*');
Expand Down
18 changes: 16 additions & 2 deletions app/code/Magento/Customer/Controller/Account/CreatePassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,27 @@
namespace Magento\Customer\Controller\Account;

use Magento\Customer\Api\AccountManagementInterface;
use Magento\Customer\Controller\AccountInterface;
use Magento\Customer\Model\Session;
use Magento\Framework\App\Action\Action;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Context;

class CreatePassword extends \Magento\Customer\Controller\Account
class CreatePassword extends Action implements AccountInterface
{
/** @var AccountManagementInterface */
protected $accountManagement;

/**
* @var Session
*/
protected $session;

/**
* @var PageFactory
*/
protected $resultPageFactory;

/**
* @param Context $context
* @param Session $customerSession
Expand All @@ -28,8 +40,10 @@ public function __construct(
PageFactory $resultPageFactory,
AccountManagementInterface $accountManagement
) {
$this->session = $customerSession;
$this->resultPageFactory = $resultPageFactory;
$this->accountManagement = $accountManagement;
parent::__construct($context, $customerSession, $resultPageFactory);
parent::__construct($context);
}

/**
Expand Down
Loading

0 comments on commit b4128b2

Please sign in to comment.