Skip to content

Commit 3691914

Browse files
committed
Merge branch 'MAGETWO-35324' of github.corp.ebay.com:magento-troll/magento2ce into develop
2 parents 33bbdfd + e5ee92e commit 3691914

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

app/code/Magento/Contact/Block/ContactForm.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,14 @@ public function __construct(Template\Context $context, array $data = [])
2121
parent::__construct($context, $data);
2222
$this->_isScopePrivate = true;
2323
}
24+
25+
/**
26+
* Returns action url for contact form
27+
*
28+
* @return string
29+
*/
30+
public function getFormAction()
31+
{
32+
return $this->getUrl('contact/index/post', ['_secure' => true]);
33+
}
2434
}

app/code/Magento/Contact/Controller/Index/Index.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ class Index extends \Magento\Contact\Controller\Index
1616
public function execute()
1717
{
1818
$this->_view->loadLayout();
19-
$this->_view->getLayout()
20-
->getBlock('contactForm')
21-
->setFormAction($this->_url->getUrl('*/*/post', ['_secure' => true]));
2219
$this->_view->renderLayout();
2320
}
2421
}

app/code/Magento/Contact/Controller/Index/Post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ public function execute()
6565
$this->messageManager->addSuccess(
6666
__('Thanks for contacting us with your comments and questions. We\'ll respond to you very soon.')
6767
);
68-
$this->_redirect('*/*/');
68+
$this->_redirect('contact/index');
6969
return;
7070
} catch (\Exception $e) {
7171
$this->inlineTranslation->resume();
7272
$this->messageManager->addError(
7373
__('We can\'t process your request right now. Sorry, that\'s all we know.')
7474
);
75-
$this->_redirect('*/*/');
75+
$this->_redirect('contact/index');
7676
return;
7777
}
7878
}

app/code/Magento/Contact/Test/Unit/Block/ContactFormTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,29 @@ class ContactFormTest extends \PHPUnit_Framework_TestCase
2020
*/
2121
protected $contextMock;
2222

23+
/**
24+
* @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
protected $urlBuilderMock;
27+
2328
/**
2429
* {@inheritDoc}
2530
*/
2631
protected function setUp()
2732
{
2833
$this->contextMock = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context')
2934
->disableOriginalConstructor()
35+
->setMethods(['getUrlBuilder'])
3036
->getMock();
3137

38+
$this->urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface')
39+
->disableOriginalConstructor()
40+
->getMock();
41+
42+
$this->contextMock->expects($this->any())
43+
->method('getUrlBuilder')
44+
->willReturn($this->urlBuilderMock);
45+
3246
$this->contactForm = new ContactForm(
3347
$this->contextMock
3448
);
@@ -41,4 +55,15 @@ public function testScope()
4155
{
4256
$this->assertTrue($this->contactForm->isScopePrivate());
4357
}
58+
59+
/**
60+
* @return void
61+
*/
62+
public function testGetFormAction()
63+
{
64+
$this->urlBuilderMock->expects($this->once())
65+
->method('getUrl')
66+
->with('contact/index/post', ['_secure' => true]);
67+
$this->contactForm->getFormAction();
68+
}
4469
}

0 commit comments

Comments
 (0)