Commit 51dd76f0 authored by Patrick Barroca's avatar Patrick Barroca 🎮

Merge branch...

Merge branch 'hotline#91864_lettre_d_information_rien_n_est_selectionne_et_pourtant_tout_est_envoye' into 'hotline'

hotline #91864 : fix newsletter articles selection

See merge request afi/opacce!3120
parents 8b05c8f1 18d653d1
- ticket #91864 : Newsletter : correction de la sélection d'article qui ajoutait automatiquement tous les articles lorsque la sélection était vide
\ No newline at end of file
......@@ -223,9 +223,11 @@ class Class_Newsletter extends Storm_Model_Abstract {
public function getArticles() {
return Class_Article::getArticlesByPreferences(['id_items' => $this->getArticlesIds(),
'id_categorie' => $this->getArticlesCategoriesIds(),
'display_order' => 'Selection']);
return $this->hasArticlesIds() || $this->hasArticlesCategoriesIds()
? Class_Article::getArticlesByPreferences(['id_items' => $this->getArticlesIds(),
'id_categorie' => $this->getArticlesCategoriesIds(),
'display_order' => 'Selection'])
: [];
}
......
......@@ -838,10 +838,10 @@ class Admin_NewsletterControllerSendActionWithCommandFailureTest extends Admin_N
abstract class Admin_NewsletterControllerPreviewActionTestCase
extends Admin_NewsletterControllerTestCase {
class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterControllerTestCase {
public function setUp() {
parent::setUp();
$marcus = $this->fixture('Class_Users', ['id' => 345,
'login' => 'mmiller',
......@@ -912,22 +912,34 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro
$septante_millions,
$gilet_jaune,
$l_arnaque]);
}
}
class Admin_NewsletterControllerPreviewActionWithArticlesSelectionTest
extends Admin_NewsletterControllerPreviewActionTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/admin/newsletter/preview/id/3', true);
}
public function testFrom() {
/** @test */
public function fromShouldBeLaurentAtAfiSaDotNet() {
$this->assertQueryContentContains('p', 'laurent@afi-sa.net');
}
public function testSubject() {
/** @test */
public function subjectShouldBeNouveautes() {
$this->assertQueryContentContains('p', 'Nouveautés');
}
public function testBodyText() {
/** @test */
public function bodyTextShouldBeNotreSelectionDuMois() {
$this->assertQueryContentContains('p', 'Notre sélection du mois Hoho');
}
......@@ -1016,6 +1028,27 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro
}
/** @see http://forge.afi-sa.fr/issues/91864 */
class Admin_NewsletterControllerPreviewActionWithoutArticlesSelectionTest
extends Admin_NewsletterControllerPreviewActionTestCase {
public function setUp() {
parent::setUp();
Class_Newsletter::find(3)
->updateAttributes(['articles_categories_ids' => '',
'articles_ids' => ''])
->assertSave();
$this->dispatch('/admin/newsletter/preview/id/3', true);
}
/** @test */
public function shouldNotCallArticlesGetByPreferences() {
$this->assertFalse(Class_Article::getLoader()->methodHasBeenCalled('getArticlesByPreferences'));
}
}
class Admin_NewsletterControllerSendTestActionTest extends Admin_NewsletterControllerTestCase {
......
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