Commit 9afdf6ef authored by Patrick Barroca's avatar Patrick Barroca 🎮

Merge branch...

Merge branch 'hotline#87795_inclure_des_articles_dans_les_lettres_d_information_images_ko_et_ordre_des_articles_ko' into 'hotline'

hotline#87795 : fix Newsletter articles order by selection

See merge request afi/opacce!3112
parents 9281058b 14c92ff3
- ticket #87795 : Newsletter : Affichage des articles dans l'ordre de selection.
\ No newline at end of file
...@@ -223,19 +223,9 @@ class Class_Newsletter extends Storm_Model_Abstract { ...@@ -223,19 +223,9 @@ class Class_Newsletter extends Storm_Model_Abstract {
public function getArticles() { public function getArticles() {
$articles = []; return Class_Article::getArticlesByPreferences(['id_items' => $this->getArticlesIds(),
'id_categorie' => $this->getArticlesCategoriesIds(),
foreach (Class_ArticleCategorie::findAllBy(['id_cat' => $this->_idsFrom($this->getArticlesCategoriesIds())]) as $categorie) 'display_order' => 'Selection']);
$articles = array_merge($articles,
$categorie->getArticles());
return array_merge($articles,
Class_Article::findAllBy(['id_article' => $this->_idsFrom($this->getArticlesIds())]));
}
protected function _idsFrom($selection) {
return explode('-', $selection);
} }
......
...@@ -879,7 +879,7 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro ...@@ -879,7 +879,7 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro
'titre' => 'L\'arnaque', 'titre' => 'L\'arnaque',
'contenu' => 'La révolution a oublié de décapiter la misère et l\'exploitation.']); 'contenu' => 'La révolution a oublié de décapiter la misère et l\'exploitation.']);
$l_arnaque = $this->fixture('Class_Article', $gilet_jaune = $this->fixture('Class_Article',
['id' => 13, ['id' => 13,
'titre' => 'Gilets Jaunes', 'titre' => 'Gilets Jaunes',
'contenu' => '<a href="'.BASE_URL.'/viewarticle/gilets-jaunes"> La révolution a commencé.<img src=\'/userfiles/jaunes.gif\' /> . <img SRC="/userfiles/gilets.gif" /></a><a href="http://lienexterne/maquereau"><img src=\'http://imageexterne/maquereau.gif\' /></a>', ]); 'contenu' => '<a href="'.BASE_URL.'/viewarticle/gilets-jaunes"> La révolution a commencé.<img src=\'/userfiles/jaunes.gif\' /> . <img SRC="/userfiles/gilets.gif" /></a><a href="http://lienexterne/maquereau"><img src=\'http://imageexterne/maquereau.gif\' /></a>', ]);
...@@ -898,7 +898,7 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro ...@@ -898,7 +898,7 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro
'nb_notices' => 0, 'nb_notices' => 0,
'id_panier' => null, 'id_panier' => null,
'articles_categories_ids' => '99-89', 'articles_categories_ids' => '99-89',
'articles_ids' => '12-13', 'articles_ids' => '13-12',
'last_distribution_date' => '2012-03-02']); 'last_distribution_date' => '2012-03-02']);
...@@ -906,6 +906,13 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro ...@@ -906,6 +906,13 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro
'libelle' => 'Portail', 'libelle' => 'Portail',
'mail_site' => 'laurent@afi-sa.net']); 'mail_site' => 'laurent@afi-sa.net']);
$this->onLoaderOfModel('Class_Article')
->whenCalled('getArticlesByPreferences')
->answers([$le_roi_des_cons,
$septante_millions,
$gilet_jaune,
$l_arnaque]);
$this->dispatch('/admin/newsletter/preview/id/3', true); $this->dispatch('/admin/newsletter/preview/id/3', true);
} }
...@@ -925,6 +932,16 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro ...@@ -925,6 +932,16 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro
} }
/** @test */
public function getArticlesByPreferencesShouldBeCalledWithParams() {
$this->assertEquals(['id_items' => '13-12',
'id_categorie' => '99-89',
'display_order' => 'Selection'],
Class_Article::getLoader()
->getFirstAttributeForLastCallOn('getArticlesByPreferences'));
}
/** @test */ /** @test */
public function noticeShouldBePresent() { public function noticeShouldBePresent() {
$this->assertQueryContentContains('p', 'Martine à la plage', $this->_response->getBody()); $this->assertQueryContentContains('p', 'Martine à la plage', $this->_response->getBody());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment