Skip to content
Snippets Groups Projects
Commit 395ff9f3 authored by Laurent's avatar Laurent
Browse files

hotline #41580 premier chapitre: on action premier-chapitre/liste-complete, limit result size to 50

parent 9fbf8d26
Branches
Tags
5 merge requests!1797Master,!1778Master,!1777Hotline master,!1776Stable,!1769hotline #41580 premier chapitre: on action premier-chapitre/liste-complete, limit result size to 50
- ticket #41580 : Premier Chapitre : sur l'action premier-chapitre/liste-complete , limitation à 50 vignettes affichées
\ No newline at end of file
......@@ -51,10 +51,10 @@ class PremierChapitreLoader extends Storm_Model_Loader {
$nb_par_page);
if (empty($ids))
return [];
return $this->findAllBy(['ean' => $ids, 'order' => 'titre ASC']);
return Class_PremierChapitre::findAllBy(['ean' => $ids, 'order' => 'titre ASC']);
}
public function getAll($nb_par_page, $page_no=1) {
public function getAll($nb_par_page = 50, $page_no=1) {
$req = "select t.`ean` from premier_chapitre t left join notices n on replace(n.`isbn`,'-','') = t.`ean` or n.`clef_oeuvre` = t.`clef_oeuvre` where n.`id_notice` is not null";
if ($nb_par_page) return $this->findAllByRequete($req,$nb_par_page,$page_no);
else return $this->findAllByRequete($req);
......
......@@ -36,6 +36,27 @@ class PremierChapitreWithFourBooksTest extends ModelTestCase {
}
/** @test */
public function getAllShouldHaveDefaultLimitTo50() {
$mock_sql = Storm_Test_ObjectWrapper::mock();
$mock_sql
->whenCalled('fetchAllByColumn')
->with("select t.`ean` from premier_chapitre t left join notices n on replace(n.`isbn`,'-','') = t.`ean` or n.`clef_oeuvre` = t.`clef_oeuvre` where n.`id_notice` is not null")
->answers(range(1, 100, 1))
->beStrict();
Storm_Cache::setDefaultZendCache(null);
Zend_Registry::set('sql', $mock_sql);
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_PremierChapitre')
->whenCalled('findAllBy')
->with(['ean' => range(1, 50, 1), 'order' => 'titre ASC'])
->answers('some books');
$this->assertEquals('some books', Class_PremierChapitre::getAll());
}
/** @test */
public function numberOfPremierChapitreInstancesShouldBeFour() {
$this->assertCount(4, Class_PremierChapitre::findAll());
......
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