Display popup form on the page

[MAILPOET-2741]
This commit is contained in:
Pavel Dohnal
2020-03-25 09:19:57 +01:00
committed by Veljko V
parent b5ce2a97c9
commit de0f31d0ee
2 changed files with 64 additions and 2 deletions

View File

@@ -224,6 +224,37 @@ class DisplayFormInWPContentTest extends \MailPoetUnitTest {
$this->hook->display('content');
}
public function testAppendsRenderedPopupForm() {
$formHtml = '<form id="test-form"></form>';
$this->wp->expects($this->once())->method('isSingle')->willReturn(false);
$this->wp->expects($this->any())->method('isPage')->willReturn(true);
$this->assetsController->expects($this->once())->method('setupFrontEndDependencies');
$this->templateRenderer->expects($this->once())->method('render')->willReturn($formHtml);
$this->wp
->expects($this->never())
->method('setTransient');
$form = new FormEntity('My Form');
$form->setSettings([
'segments' => ['3'],
'place_form_bellow_all_pages' => '',
'place_form_bellow_all_posts' => '',
'place_popup_form_on_all_pages' => '1',
'place_popup_form_on_all_posts' => '',
'success_message' => 'Hello',
]);
$form->setBody([[
'type' => 'submit',
'params' => ['label' => 'Subscribe!'],
'id' => 'submit',
'name' => 'Submit',
]]);
$this->repository->expects($this->once())->method('findBy')->willReturn([$form]);
$result = $this->hook->display('content');
expect($result)->notEquals('content');
expect($result)->endsWith($formHtml);
}
public function _after() {
parent::_after();
WPFunctions::set(new WPFunctions());