Skip to content
Snippets Groups Projects

dev#160166 : CkEditor placeholders plugin

Merged Alex Arnaud requested to merge dev#160166_newsletters_placeholders into master
All threads resolved!
Compare and Show latest version
4 files
+ 86
94
Preferences
Compare changes
Files
4
@@ -1016,6 +1016,7 @@ abstract class Admin_NewsletterControllerPreviewActionTestCase
abstract class Admin_NewsletterControllerPreviewActionPlaceHoldersTestCase extends Admin_NewsletterControllerPreviewActionTestCase{
protected Class_Newsletter $_newsletter;
protected string $_file_path = '';
public function setUp() {
parent::setUp();
@@ -1025,7 +1026,6 @@ abstract class Admin_NewsletterControllerPreviewActionPlaceHoldersTestCase exten
/*
// This Should have been enough to get Martine for widget
// But there is a Zend_Registry::get('sql') in MoteurRecherche_Result->fetchFromCache
// should change when new search is merged
Class_AdminVar::set('CACHE_ACTIF', 1);
Storm_Cache::beVolatile();
@@ -1067,6 +1067,11 @@ abstract class Admin_NewsletterControllerPreviewActionPlaceHoldersTestCase exten
}
public function expectedLine() {
return array_map(fn($elt)=> [$elt],file($this->_file_path));
}
/** @test */
public function placeholderNewsletterRecordsShouldHaveBeenRemoved() {
$this->assertNotXPathContentContains('//body', '[newsletter_records]');
@@ -1077,6 +1082,14 @@ abstract class Admin_NewsletterControllerPreviewActionPlaceHoldersTestCase exten
public function placeholderNewsletterArticlesShouldHaveBeenRemoved() {
$this->assertNotXPathContentContains('//body', '[newsletter_articles]');
}
/** @test
* @dataProvider expectedLine
*/
public function contentShouldBeAsExpected(string $expected_line) {
$this->assertContains( $expected_line, $this->_response->getBody());
}
}
@@ -1086,52 +1099,9 @@ abstract class Admin_NewsletterControllerPreviewActionPlaceHoldersTestCase exten
class Admin_NewsletterControllerPreviewActionWithArticlesSelectionAndPlaceHoldersTest
extends Admin_NewsletterControllerPreviewActionPlaceHoldersTestCase {
protected function _expectedText() {
return <<<'TEXT'
<p>
Top<br />
- Martine à la plage<br />
<br />
Lien: http://localhost/html/recherche/viewnotice/clef/MARTINEALAPLAGE/id/42<br />
<br />
<br />
Middle<br />
- Le Roi des consIl est beau, il est fier sur son throne.Lien: http://localhost/html/cms/viewarticle/id/36<br />
<br />
- 70 millions …Ils sont 70 millions prêts à prendre sa place.Lien: http://localhost/html/cms/viewarticle/id/35<br />
<br />
- Gilets Jaunes La révolution a commencé. . Lien: http://localhost/html/cms/viewarticle/id/13<br />
<br />
- L'arnaqueLa révolution a oublié de décapiter la misère et l'exploitation.Lien: http://localhost/html/cms/viewarticle/id/12<br />
<br />
footer<br />
Lien pour se désinscrire de cette lettre d'information : http://localhost/html/newsletter/unsubscribe/newsletter/3/user//hash/6dd28e9b</p>
TEXT;
}
protected function _expectedHtml() {
return <<<'PAGE_HTML'
<div>
Top
<div style="padding:5px"><a href="http://localhost/html/recherche/viewnotice/clef/MARTINEALAPLAGE/id/42">Martine à la plage</a><div></div><div style="clear:both"></div></div>
Middle
<div style="padding:5px"><h1>Le Roi des cons</h1><div>Il est beau, il est fier sur son throne.</div><div style="clear:both"></div></div><div style="padding:5px"><h1>70 millions …</h1><div>Ils sont 70 millions prêts à prendre sa place.</div><div style="clear:both"></div></div><div style="padding:5px"><h1>Gilets Jaunes</h1><div><a href="http://localhost/html/viewarticle/gilets-jaunes"> La révolution a commencé.<img src='http://localhost/html/userfiles/jaunes.gif' /> . <img SRC="http://localhost/html/userfiles/gilets.gif" /></a><a href="http://lienexterne/maquereau"><img src='http://imageexterne/maquereau.gif' /></a></div><div style="clear:both"></div></div><div style="padding:5px"><h1>L'arnaque</h1><div>La révolution a oublié de décapiter la misère et l'exploitation.</div><div style="clear:both"></div></div>
footer<br/><a href="http://localhost/html/newsletter/unsubscribe/newsletter/3/user//hash/6dd28e9b">
PAGE_HTML;
}
protected string $_file_path =__DIR__.'/newsletter_placeholder_content_expected.txt';
/** @test */
public function contentTextShouldBeAsExpected() {
$this->assertContains( $this->_expectedText(), $this->_response->getBody());
}
/** @test */
public function contentHtmlShouldBeAsExpected() {
$this->assertContains( $this->_expectedHtml(), $this->_response->getBody());
}
}
@@ -1140,36 +1110,12 @@ PAGE_HTML;
class Admin_NewsletterControllerPreviewActionWithPlaceHoldersWithoutCatalogueTest
extends Admin_NewsletterControllerPreviewActionPlaceHoldersTestCase {
protected string $_file_path = __DIR__.'/newsletter_placeholder_content_without_catalogue_expected.txt';
protected function _customizeNewsletter(Class_Newsletter $newsletter) {
$newsletter
->setIdCatalogue(0);
}
protected function _expectedText() {
return <<<'TEXT2'
<p>
Top<br />
<br />
Middle<br />
- Le Roi des consIl est beau, il est fier sur son throne.Lien: http://localhost/html/cms/viewarticle/id/36<br />
<br />
- 70 millions …Ils sont 70 millions prêts à prendre sa place.Lien: http://localhost/html/cms/viewarticle/id/35<br />
<br />
- Gilets Jaunes La révolution a commencé. . Lien: http://localhost/html/cms/viewarticle/id/13<br />
<br />
- L'arnaqueLa révolution a oublié de décapiter la misère et l'exploitation.Lien: http://localhost/html/cms/viewarticle/id/12<br />
<br />
footer<br />
Lien pour se désinscrire de cette lettre d'information : http://localhost/html/newsletter/unsubscribe/newsletter/3/user//hash/6dd28e9b</p>
TEXT2;
}
/** @test */
public function pageShouldContainsExpectedText() {
$this->assertContains($this->_expectedText(), $this->_response->getBody());
}
}
@@ -1178,34 +1124,13 @@ TEXT2;
class Admin_NewsletterControllerPreviewActionWithPlaceholdersWithoutArticlesTest
extends Admin_NewsletterControllerPreviewActionPlaceHoldersTestCase {
protected string $_file_path = __DIR__.'/newsletter_placeholder_content_without_articles.txt';
protected function _customizeNewsletter(Class_Newsletter $newsletter) {
$newsletter
->setArticlesIds(0)
->setArticlesCategoriesIds(0);
}
protected function _expectedText() {
return <<<'TEXT_NOARTICLES'
<p>
Top<br />
- Martine à la plage<br />
<br />
Lien: http://localhost/html/recherche/viewnotice/clef/MARTINEALAPLAGE/id/42<br />
<br />
<br />
Middle<br />
<br />
footer<br />
Lien pour se désinscrire de cette lettre d'information : http://localhost/html/newsletter/unsubscribe/newsletter/3/user//hash/6dd28e9b</p>
TEXT_NOARTICLES;
}
/** @test */
public function pageShouldContainsExpectedText() {
$this->assertContains($this->_expectedText(), $this->_response->getBody());
}
}
@@ -1230,6 +1155,12 @@ class Admin_NewsletterControllerPreviewActionWithPlaceHoldersAndRenderWidgetTest
public function pageShouldContainsBoiteArticleWithTitleExpected() {
$this->assertXPathContentContains('//div[@class="widget-body"]//div[@class="list-group-item"]//div[@class="card"]//div[@role="heading"]//a', 'Gilets Jaunes');
}
/**
* @group ignore
*/
public function contentShouldBeAsExpected(string $expected_line) {}
}
@@ -1256,6 +1187,12 @@ class Admin_NewsletterControllerPreviewActionWithPlaceHoldersAndRenderWidgetWith
public function pageShouldNotRenderBoiteArticle() {
$this->assertContains("Middle\n\nfooter<br/>", $this->_response->getBody());
}
/**
* @group ignore
*/
public function contentShouldBeAsExpected(string $expected_line) {}
}
@@ -1282,6 +1219,12 @@ class Admin_NewsletterControllerPreviewActionWithPlaceHoldersAndRenderWidgetWith
public function pageShouldContainsBoiteArticleWithTitleExpected() {
$this->assertXPathContentContains('//div[@class="widget-body"]//div[@class="list-group-item"]//div[@class="card"]//div[@role="heading"]//a', 'Gilets Jaunes');
}
/**
* @group ignore
*/
public function contentShouldBeAsExpected(string $expected_line) {}
}