Skip to content
Snippets Groups Projects
Commit 9afdf6ef authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

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 !3112
parents 9281058b 14c92ff3
Branches
Tags
3 merge requests!3297WIP: Master,!3125Hotline,!3112hotline#87795 : fix Newsletter articles order by selection
Pipeline #6944 passed with stage
in 38 minutes and 34 seconds
- 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 {
public function getArticles() {
$articles = [];
foreach (Class_ArticleCategorie::findAllBy(['id_cat' => $this->_idsFrom($this->getArticlesCategoriesIds())]) as $categorie)
$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);
return Class_Article::getArticlesByPreferences(['id_items' => $this->getArticlesIds(),
'id_categorie' => $this->getArticlesCategoriesIds(),
'display_order' => 'Selection']);
}
......
......@@ -879,7 +879,7 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro
'titre' => 'L\'arnaque',
'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,
'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>', ]);
......@@ -898,7 +898,7 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro
'nb_notices' => 0,
'id_panier' => null,
'articles_categories_ids' => '99-89',
'articles_ids' => '12-13',
'articles_ids' => '13-12',
'last_distribution_date' => '2012-03-02']);
......@@ -906,6 +906,13 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro
'libelle' => 'Portail',
'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);
}
......@@ -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 */
public function noticeShouldBePresent() {
$this->assertQueryContentContains('p', 'Martine à la plage', $this->_response->getBody());
......
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