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

hotline #147804 More tests fixing

parent c5e48629
No related merge requests found
Pipeline #16196 failed with stage
in 21 minutes and 18 seconds
......@@ -988,11 +988,11 @@ class MoteurRechercheWithCatalogueAndParamsTest extends MoteurRechercheWithCatal
Class_MoteurRecherche::setTimeSource(new TimeSourceForTest('2014-12-23 09:00:00'));
Class_Profil::getCurrentProfil()->setSelAnnexe('2;4;1');
$this->fixture('Class_Catalogue',
$this->fixture(Class_Catalogue::class,
['id' => 5,
'libelle' => 'Dernières news',
'nouveaute' => 1,
'type_doc' => '1;4' ]);
'type_doc' => '1;4']);
$this->mock_sql
->whenCalled('fetchAll')
......@@ -1013,16 +1013,16 @@ class MoteurRechercheWithCatalogueAndParamsTest extends MoteurRechercheWithCatal
[1, '']
]);
$criteres_recherche = (new Class_CriteresRecherche())
$criteres_recherche = (new Class_CriteresRecherche)
->setParams(['id_catalogue' => 5,
'aleatoire' => 1,
'tri' => 'date_creation+desc',
'tri' => 'date_creation desc',
'fil' => ';X1',
'rubrique' =>'P4',
'selection_annexe' => ' ',
'style_liste' => '']);
$this->request = (new Class_MoteurRecherche())->lancerRecherche($criteres_recherche);
$this->request = (new Class_MoteurRecherche)->lancerRecherche($criteres_recherche);
$this->assertEquals($query, $this->request->getRecordsQuery());
}
......@@ -1037,7 +1037,7 @@ class MoteurRechercheWithCatalogueAndUrlParamsTest extends MoteurRechercheWithCa
Class_Profil::getCurrentProfil()->setSelAnnexe('');
Class_MoteurRecherche::setTimeSource(new TimeSourceForTest('2014-12-23 09:00:00'));
$this->fixture('Class_Catalogue',
$this->fixture(Class_Catalogue::class,
['id' => 5,
'libelle' => 'Our domain',
'type_doc' => '1;4' ]);
......@@ -1046,11 +1046,10 @@ class MoteurRechercheWithCatalogueAndUrlParamsTest extends MoteurRechercheWithCa
/** @test */
public function requestShouldUseProfilSettings() {
$criteres_recherche =
(new Class_CriteresRecherche())->setParams(['id_catalogue' => 5,
'tri' => 'annee+desc',
'facettes' =>'T1-T10',
'facette' => 'T5']);
$criteres_recherche = (new Class_CriteresRecherche)->setParams(['id_catalogue' => 5,
'tri' => 'annee desc',
'facettes' =>'T1-T10',
'facette' => 'T5']);
$query = $this->listSqlWith('((MATCH(facettes) AGAINST(\'+(T1 T4)\' IN BOOLEAN MODE)) or MATCH(facettes) AGAINST(\'Q5\' IN BOOLEAN MODE)) and MATCH(facettes) AGAINST(\'+T1 +T10 +T5\' IN BOOLEAN MODE)',
'annee desc');
......@@ -1062,7 +1061,7 @@ class MoteurRechercheWithCatalogueAndUrlParamsTest extends MoteurRechercheWithCa
[1, '']
]);
$this->request = (new Class_MoteurRecherche())->lancerRecherche($criteres_recherche);
$this->request = (new Class_MoteurRecherche)->lancerRecherche($criteres_recherche);
$this->assertEquals($query,
$this->request->getRecordsQuery());
......
......@@ -22,7 +22,8 @@
/* hotline: #143811 */
class TemplatesWidgetKiosqueRandomTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
protected
$_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
......@@ -53,18 +54,17 @@ class TemplatesWidgetKiosqueRandomTest extends AbstractControllerTestCase {
'type_doc' => 1
]);
for ($i = 1; $i <= 100; $i++)
$this->fixture(Class_Notice::class,
['id' => $i]);
Zend_Registry::set('sql', null);
Storm_Cache::beVolatile();
$search_result = [];
foreach (range(1, 100) as $i) {
$this->fixture(Class_Notice::class, ['id' => $i]);
$search_result[] = [$i, ''];
}
$cache = (new Storm_Cache)
->memoize(['select notices.id_notice from notices Where (notices.type_doc=\'1\') and type=1 order by url_image="no", url_image="" LIMIT 0,100',
'NoticeLoader',
'getNoticeIdsByRequeteRecherche'],
function () {return range(1, 100);});
Zend_Registry::set('sql',
$this->mock()
->whenCalled('fetchAll')
->with('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+(T1)\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="" limit 100', true, false)
->answers($search_result));
$this->dispatch('/index');
}
......@@ -87,7 +87,6 @@ class TemplatesWidgetKiosqueRandomTest extends AbstractControllerTestCase {
abstract class TemplatesWidgetKiosqueDomainTestCase extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true;
......
......@@ -1717,18 +1717,18 @@ abstract class TemplatesWidgetCarouselWithDomainTestCase extends AbstractControl
Class_Profil::DIV_MAIN,
$params);
$this->_record = $this->fixture('Class_Notice',
$this->_record = $this->fixture(Class_Notice::class,
['id' => 4,
'titre_principal' => 'Le Montespan',
'auteur_principal' => 'Jean Teul',
'clef_alpha' => 'MONTESPAN']);
$domain = $this->fixture('Class_Catalogue',
$domain = $this->fixture(Class_Catalogue::class,
['id' => 3,
'libelle' => 'art'])
->setIndexer(true);
$selection = $this->fixture('Class_PanierNotice',
$selection = $this->fixture(Class_PanierNotice::class,
['id' => 2,
'id_panier' => 2,
'libelle' => 'Mes BD',
......@@ -1741,9 +1741,10 @@ abstract class TemplatesWidgetCarouselWithDomainTestCase extends AbstractControl
$domain->assertSave();
$domain->indexWithBaskets();
$this->onLoaderOfModel('Class_Notice')
->whenCalled('findAllByRequeteRecherche')
->answers([$this->_record]);
Zend_Registry::set('sql',
$this->mock()
->whenCalled('fetchAll')
->answers([[4, '']]));
}
}
......@@ -1765,11 +1766,9 @@ class TemplatesWidgetCarouselWithDomainTest extends TemplatesWidgetCarouselWithD
/** @test */
public function recordsIdsShouldHaveBeenSelectedWithFacetQ3AndTypeBiblio() {
$this->assertEquals(['select notices.id_notice from notices Where (MATCH(facettes) AGAINST(\'Q3\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="", alpha_titre asc LIMIT 0,9',
9,
1],
Class_Notice::getAttributesForLastCallOn('findAllByRequeteRecherche'));
public function fetchAllShouldBeCalledWithQ3FacetLimit9() {
$this->assertEquals('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'Q3\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="", alpha_titre asc limit 9',
Zend_Registry::get('sql')->getFirstAttributeForLastCallOn('fetchAll'));
}
......@@ -1805,11 +1804,9 @@ class TemplatesWidgetCarouselWithDomainFindByIdsTest extends TemplatesWidgetCaro
/** @test */
public function findAllByIdsShouldHaveBeenCalledWithLimit100AndPage1() {
$this->assertEquals(['select notices.id_notice from notices Where (MATCH(facettes) AGAINST(\'Q3\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="" LIMIT 0,100',
100,
1],
Class_Notice::getAttributesForLastCallOn('findAllByRequeteRecherche'));
public function fetchAllShouldBeCalledWithQ3FacetLimit100() {
$this->assertEquals('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'Q3\' IN BOOLEAN MODE)) and type=1 order by url_image="no", url_image="" limit 100',
Zend_Registry::get('sql')->getFirstAttributeForLastCallOn('fetchAll'));
}
}
......
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