diff --git a/VERSIONS_HOTLINE/155500 b/VERSIONS_HOTLINE/155500 new file mode 100644 index 0000000000000000000000000000000000000000..e4140b2c3b483f2afc656d0f420d634edf3d4997 --- /dev/null +++ b/VERSIONS_HOTLINE/155500 @@ -0,0 +1 @@ + - correctif #155500 : Ressources Bacon : correction de la détection du type de document comme étant une ressource numérique. Cela a pour conséquence de supprimer le bouton réserver pour ces documents. \ No newline at end of file diff --git a/library/Class/StatsNotices.php b/library/Class/StatsNotices.php index e9177b3ba40961b00ea56114e9d332ad9a22dcdf..ac55c190745b85b8bd3af3eda5c6ce36f1667d47 100644 --- a/library/Class/StatsNotices.php +++ b/library/Class/StatsNotices.php @@ -20,8 +20,14 @@ */ class Class_StatsNotices { - private $lib_mois = ['', 'janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', - 'août', 'septembre', 'octobre', 'novembre', 'décembre']; + + use Trait_TimeSource; + + + private $lib_mois = + ['', 'janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', + 'août', 'septembre', 'octobre', 'novembre', 'décembre']; + public function addStatVisu($id_notice) { if ($this->_isBlackListed()) @@ -38,8 +44,9 @@ class Class_StatsNotices { protected function _addStat($id_notice, $field) { - $annee = date('Y'); - $mois = date('m'); + $now = $this->getCurrentTime(); + $annee = date('Y', $now); + $mois = date('m', $now); // @see http://forge.afi-sa.fr/issues/23151 /* diff --git a/library/digital_resources/Bacon/Config.php b/library/digital_resources/Bacon/Config.php index 5e4c092431a04c510aae0a68f9639deec6d4259f..3e92aaa67ee6805a61273f4d681fed6b07ac51c9 100644 --- a/library/digital_resources/Bacon/Config.php +++ b/library/digital_resources/Bacon/Config.php @@ -197,4 +197,12 @@ class Bacon_Config extends Class_DigitalResource_Config { ARRAY_FILTER_USE_KEY) : []; } + + + public function isDocTypeHandled($type) { + return ( false !== strpos($type, $this->getDoctypeId())) + ? in_array(str_replace($this->getDoctypeId(), '', $type), + array_keys($this->_documentTypes())) + : false; + } } diff --git a/library/digital_resources/Bacon/tests/BaconTest.php b/library/digital_resources/Bacon/tests/BaconTest.php index a4d6e6dd77a9fee7414ac0ab3979a1431174f335..c1ab9a037050f3da253dce677016bfa7502d422e 100644 --- a/library/digital_resources/Bacon/tests/BaconTest.php +++ b/library/digital_resources/Bacon/tests/BaconTest.php @@ -21,9 +21,8 @@ abstract class BaconActivatedTestCase extends AbstractControllerTestCase { - protected - $_storm_default_to_volatile = true, - $_user; + + protected $_user; public function setUp() { parent::setUp(); @@ -60,11 +59,10 @@ abstract class BaconActivatedTestCase extends AbstractControllerTestCase { class BaconDashboardUnactivatedTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - public function setUp() { parent::setUp(); + $sql = $this->mock() ->whenCalled('fetchAll') ->with("select type_doc, count(*) as nb_notices from notices where type_doc like 'Bacon%' group by type_doc", false, false) @@ -73,7 +71,7 @@ class BaconDashboardUnactivatedTest extends Admin_AbstractControllerTestCase { Zend_Registry::set('sql', $sql); - $this->dispatch('/Bacon_Plugin', true); + $this->dispatch('/Bacon_Plugin'); } @@ -117,7 +115,6 @@ class BaconDashboardUnactivatedTest extends Admin_AbstractControllerTestCase { class BaconHarvestSetVariableEditTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); @@ -140,7 +137,7 @@ class BaconHarvestSetVariableEditTest extends Admin_AbstractControllerTestCase { class BaconDocumentTypesVariablePostTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); @@ -301,7 +298,7 @@ class BaconDashboardActivatedTest extends BaconActivatedTestCase { 'login' => 'admin', 'password' => 'admin', 'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN])); - $this->dispatch('/Bacon_Plugin', true); + $this->dispatch('/Bacon_Plugin'); } @@ -325,6 +322,7 @@ class BaconDashboardActivatedTest extends BaconActivatedTestCase { abstract class BaconHarvestingTestCase extends BaconActivatedTestCase { + protected $_http_client, $_service, @@ -332,6 +330,7 @@ abstract class BaconHarvestingTestCase extends BaconActivatedTestCase { $_delete_by_called = false, $_log; + public function setUp() { parent::setUp(); @@ -395,7 +394,8 @@ abstract class BaconHarvestingTestCase extends BaconActivatedTestCase { -class BaconHarvestingSimpleTest extends BaconHarvestingTestCase { +abstract class BaconHarvestingAndIndexingTestCase extends BaconHarvestingTestCase { + protected $_album, $_record; @@ -415,6 +415,12 @@ class BaconHarvestingSimpleTest extends BaconHarvestingTestCase { Class_Album::clearCache(); } +} + + + + +class BaconHarvestingSimpleTest extends BaconHarvestingAndIndexingTestCase { /** @test */ @@ -515,6 +521,18 @@ class BaconHarvestingSimpleTest extends BaconHarvestingTestCase { public function logShouldContains13Kbarts() { $this->assertContains('13 kbarts', $this->_log); } + + + /** @test */ + public function recordDocTypeShouldBeIstexJoural() { + $this->assertEquals('Istex Journals', $this->_record->getTypeDocLabel()); + } + + + /** @test */ + public function recordShouldBeADigitalResource() { + $this->assertTrue($this->_record->isRessourceNumerique()); + } } @@ -606,3 +624,36 @@ class BaconHarvestingDedupTest extends BaconHarvestingTestCase { $this->assertEquals(1, Class_Album::count()); } } + + + + +class BaconViewNoticeIndexedTest extends BaconHarvestingAndIndexingTestCase { + + public function setUp() { + parent::setUp(); + $this->_buildTemplateProfil([ 'id' => '2']); + + Zend_Registry::get('sql') + ->whenCalled('fetchOne') + ->answers(true) + + ->whenCalled('execute') + ->answers(true); + + $this->dispatch('/recherche/viewnotice/id/' . $this->_record->getId()); + } + + + /** @test */ + public function holdLinkShouldNotBeDisplayed() { + $this->assertNotXPathContentContains('//body', 'Réserver'); + } + + + /** @test */ + public function pageshouldContainsH1Nature() { + $this->assertXPathContentContains('//body[@data-template="INTONATION"]//div//h1', + 'Nature'); + } +} diff --git a/tests/TearDown.php b/tests/TearDown.php index 6362d665504494384a6b66265baa7011dae58305..e7643e8e464327189940544df8fc4cac5b4bd636 100644 --- a/tests/TearDown.php +++ b/tests/TearDown.php @@ -72,6 +72,7 @@ class TearDown { Class_Notice_Xsl::reset(); Class_Notice::setTimeSource(null); Class_Notice_Facette::reset(); + Class_StatsNotices::setTimeSource(null); Class_Profil::getCurrentProfil()->clearInstanceCache(); Class_Profil::clearCache(); diff --git a/tests/scenarios/Templates/TemplatesRecordsTest.php b/tests/scenarios/Templates/TemplatesRecordsTest.php index b2673ad9b62e1770b5245067851f0f97633015e9..162f0c81eeae093d2d54e07c725b87c70b0c9c04 100644 --- a/tests/scenarios/Templates/TemplatesRecordsTest.php +++ b/tests/scenarios/Templates/TemplatesRecordsTest.php @@ -1452,6 +1452,8 @@ class TemplatesRecordsPaginationTest extends AbstractControllerTestCase { $this->_buildTemplateProfil(['id' => 1]); + Class_StatsNotices::setTimeSource(new TimeSourceForTest('2022-05-31 10:00:00')); + $ids = range(455, 459); foreach($ids as $i) $this->fixture(Class_Notice::class, @@ -1465,12 +1467,12 @@ class TemplatesRecordsPaginationTest extends AbstractControllerTestCase { $this->mock() ->whenCalled('fetchOne') - ->with('select count(*) from stats_notices where annee=2022 and mois=06') + ->with('select count(*) from stats_notices where annee=2022 and mois=05') ->answers(4) ->whenCalled('execute') - ->with('update stats_notices set nb_visu = nb_visu + 1 where annee=2022 and mois=06') + ->with('update stats_notices set nb_visu = nb_visu + 1 where annee=2022 and mois=05') ->answers(1) ->whenCalled('fetchAll')