diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/BackButton.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/BackButton.php
index 11ca201dcdb4c..b8fa812437a5c 100644
--- a/app/code/Magento/Customer/Block/Adminhtml/Edit/BackButton.php
+++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/BackButton.php
@@ -12,6 +12,26 @@
*/
class BackButton extends GenericButton implements ButtonProviderInterface
{
+ /**
+ * @var Form
+ */
+ private $form;
+ /**
+ * @var \Magento\Framework\Url\DecoderInterface
+ */
+ private $decoder;
+
+ public function __construct(
+ \Magento\Framework\Url\DecoderInterface $decoder,
+ \Magento\Customer\Block\Adminhtml\Edit\Form $form,
+ \Magento\Backend\Block\Widget\Context $context,
+ \Magento\Framework\Registry $registry
+ ) {
+ parent::__construct($context, $registry);
+ $this->form = $form;
+ $this->decoder = $decoder;
+ }
+
/**
* @return array
*/
@@ -32,6 +52,12 @@ public function getButtonData()
*/
public function getBackUrl()
{
+ if ($fromPath=$this->decoder->decode($this->form->getRequest()->getParam('fromPath'))) {
+ return $this->getUrl(
+ $fromPath,
+ ['id' => $this->form->getRequest()->getParam('review_id')]
+ );
+ }
return $this->getUrl('*/*/');
}
}
diff --git a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php
index 346d5b60aad1b..b2d5372b02ee4 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php
@@ -36,6 +36,10 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
* @var \Magento\Store\Model\System\Store
*/
protected $_systemStore;
+ /**
+ * @var \Magento\Framework\Url\EncoderInterface
+ */
+ private $urlEncoder;
/**
* @param \Magento\Backend\Block\Template\Context $context
@@ -45,6 +49,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
* @param \Magento\Customer\APi\CustomerRepositoryInterface $customerRepository
* @param \Magento\Catalog\Model\ProductFactory $productFactory
* @param \Magento\Review\Helper\Data $reviewData
+ * @param \Magento\Framework\Url\EncoderInterface $urlEncoder
* @param array $data
*/
public function __construct(
@@ -55,12 +60,14 @@ public function __construct(
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
\Magento\Catalog\Model\ProductFactory $productFactory,
\Magento\Review\Helper\Data $reviewData,
+ \Magento\Framework\Url\EncoderInterface $urlEncoder,
array $data = []
) {
$this->_reviewData = $reviewData;
$this->customerRepository = $customerRepository;
$this->_productFactory = $productFactory;
$this->_systemStore = $systemStore;
+ $this->urlEncoder = $urlEncoder;
parent::__construct($context, $registry, $formFactory, $data);
}
@@ -120,10 +127,19 @@ protected function _prepareForm()
);
try {
+ $fromPath=$this->urlEncoder->encode('review/product/edit');
$customer = $this->customerRepository->getById($review->getCustomerId());
$customerText = __(
'%2 %3 (%4)',
- $this->getUrl('customer/index/edit', ['id' => $customer->getId(), 'active_tab' => 'review']),
+ $this->getUrl(
+ 'customer/index/edit',
+ [
+ 'id' => $customer->getId(),
+ 'active_tab' => 'review',
+ 'fromPath' => $fromPath,
+ 'review_id' => $this->getRequest()->getParam('id')
+ ]
+ ),
$this->escapeHtml($customer->getFirstname()),
$this->escapeHtml($customer->getLastname()),
$this->escapeHtml($customer->getEmail())
diff --git a/app/code/Magento/Review/Test/Mftf/ActionGroup/AdminOpenCustomerPageFromReviewActionGroup.xml b/app/code/Magento/Review/Test/Mftf/ActionGroup/AdminOpenCustomerPageFromReviewActionGroup.xml
new file mode 100644
index 0000000000000..c352221bedc79
--- /dev/null
+++ b/app/code/Magento/Review/Test/Mftf/ActionGroup/AdminOpenCustomerPageFromReviewActionGroup.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+ Open Customer Page of Review author.
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Review/Test/Mftf/Page/AdminEditReviewPage.xml b/app/code/Magento/Review/Test/Mftf/Page/AdminEditReviewPage.xml
new file mode 100644
index 0000000000000..324377b95927e
--- /dev/null
+++ b/app/code/Magento/Review/Test/Mftf/Page/AdminEditReviewPage.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Review/Test/Mftf/Section/AdminReviewDetailsSection.xml b/app/code/Magento/Review/Test/Mftf/Section/AdminReviewDetailsSection.xml
new file mode 100644
index 0000000000000..2a5f8d76d9246
--- /dev/null
+++ b/app/code/Magento/Review/Test/Mftf/Section/AdminReviewDetailsSection.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Review/Test/Mftf/Test/AdminReviewCorrectBackButtonTest.xml b/app/code/Magento/Review/Test/Mftf/Test/AdminReviewCorrectBackButtonTest.xml
new file mode 100644
index 0000000000000..065fbb12f265d
--- /dev/null
+++ b/app/code/Magento/Review/Test/Mftf/Test/AdminReviewCorrectBackButtonTest.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminClickBackButtonActionGroup.xml b/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminClickBackButtonActionGroup.xml
new file mode 100644
index 0000000000000..d5416bf94cf3d
--- /dev/null
+++ b/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminClickBackButtonActionGroup.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+ Click on 'Back' button. Validate correct page opened.
+
+
+
+
+
+
+
+
+
+