diff --git a/VERSIONS_HOTLINE/85003 b/VERSIONS_HOTLINE/85003 new file mode 100644 index 0000000000000000000000000000000000000000..585b4fffa8da50d604570516b2ce58e08f07951b --- /dev/null +++ b/VERSIONS_HOTLINE/85003 @@ -0,0 +1,3 @@ + - ticket #85003 : Administration : amélioration de la gestion de l'éditeur de CSS. + + \ No newline at end of file diff --git a/VERSIONS_HOTLINE/86175 b/VERSIONS_HOTLINE/86175 new file mode 100644 index 0000000000000000000000000000000000000000..8a9c1a6a232601ded34232ef3f8f5971e9d8fc1a --- /dev/null +++ b/VERSIONS_HOTLINE/86175 @@ -0,0 +1,2 @@ + - ticket #86175 : Intégration Cosmogramme : correction de l'import des genres. + \ No newline at end of file diff --git a/VERSIONS_HOTLINE/86808 b/VERSIONS_HOTLINE/86808 new file mode 100644 index 0000000000000000000000000000000000000000..c35ebc844a4bba87c4345e979e7fda1eae6ae62b --- /dev/null +++ b/VERSIONS_HOTLINE/86808 @@ -0,0 +1,2 @@ + - ticket #86808 : Administration : amélioration de la suppression des albums. + \ No newline at end of file diff --git a/amber/afi/js/AFI-OPAC.deploy.js b/amber/afi/js/AFI-OPAC.deploy.js index 15d163c86314ae0e76ef5534ee92ebceea2c74e5..f6caa8d00d149af224449af01ad9ecd7884d2eb2 100755 --- a/amber/afi/js/AFI-OPAC.deploy.js +++ b/amber/afi/js/AFI-OPAC.deploy.js @@ -50,11 +50,15 @@ smalltalk.addMethod( "_cssUrl", smalltalk.method({ selector: "cssUrl", -fn: function (){ +fn: function(){ var self=this; -return (($receiver = self['@cssUrl']) == nil || $receiver == undefined) ? (function(){var linkTag=nil; -(linkTag=smalltalk.send((typeof window == 'undefined' ? nil : window), "_jQuery_", [unescape("%23profil_css")]));(self['@cssUrl']=smalltalk.send(linkTag, "_attr_", ["href"]));smalltalk.send(linkTag, "_remove", []);return self['@cssUrl'];})() : $receiver; -return self;} +var linkTag; +linkTag=smalltalk.send(window,"_jQuery_",["#profil_css"]); +self["@cssUrl"]=smalltalk.send(linkTag,"_attr_",["data-url"]); +self["@cssUrl"]=smalltalk.send(self["@cssUrl"],"__comma",["?"]); +self["@cssUrl"]=smalltalk.send(self["@cssUrl"],"__comma",[smalltalk.send(smalltalk.send((smalltalk.Date || Date),"_now",[]),"_asMilliseconds",[])]); +return self["@cssUrl"]; +} }), smalltalk.AFICssEditor); @@ -73,10 +77,22 @@ smalltalk.addMethod( "_loadCss", smalltalk.method({ selector: "loadCss", -fn: function (){ +fn: function(){ var self=this; -(($receiver = smalltalk.send(self, "_cssUrl", [])) != nil && $receiver != undefined) ? (function(){return (function($rec){smalltalk.send($rec, "_onSuccessDo_", [(function(data){smalltalk.send(self, "_contents_", [data]);return smalltalk.send(self, "_updateStyleTag", []);})]);return smalltalk.send($rec, "_send", []);})(smalltalk.send((smalltalk.Ajax || Ajax), "_url_", [self['@cssUrl']]));})() : nil; -return self;} +var $1,$2,$3; +$1=smalltalk.send(self,"_cssUrl",[]); +if(($receiver = $1) == nil || $receiver == undefined){ +$1; +} else { +$2=smalltalk.send((smalltalk.Ajax || Ajax),"_url_",[self["@cssUrl"]]); +smalltalk.send($2,"_onSuccessDo_",[(function(data){ +smalltalk.send(self,"_contents_",[data]); +return smalltalk.send(self,"_updateStyleTag",[]); +})]); +$3=smalltalk.send($2,"_send",[]); +$3; +}; +return self} }), smalltalk.AFICssEditor); @@ -145,10 +161,16 @@ smalltalk.addMethod( "_close", smalltalk.method({ selector: "close", -fn: function (){ -var self=this; -(($receiver = self['@current']) != nil && $receiver != undefined) ? (function(){smalltalk.send(self['@current'], "_close", []);return (self['@current']=nil);})() : nil; -return self;} +fn: function(){ +var self=this; +if(($receiver = self["@current"]) == nil || $receiver == undefined){ +self["@current"]; +} else { +smalltalk.send(self["@current"],"_close",[]); +self["@current"]=nil; +self["@current"]; +}; +return self} }), smalltalk.AFICssEditor.klass); @@ -163,31 +185,15 @@ return self;} }), smalltalk.AFICssEditor.klass); -smalltalk.addMethod( -"_initializeold", -smalltalk.method({ -selector: "initializeold", -fn: function (){ -var self=this; -smalltalk.send(smalltalk.send((smalltalk.AFIIDETools || AFIIDETools),"_default",[]),"_addButton_action_",["Editeur CSS",(function(){ -smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.TabManager || TabManager),"_current",[]),"_tabs",[]),"_do_",[(function(aTab){ -return smalltalk.send(smalltalk.send((smalltalk.TabManager || TabManager),"_current",[]),"_removeTab_",[aTab]); -})]); -return smalltalk.send(smalltalk.send(self,"_current",[]),"_open",[]); -})]); -return self} -}), -smalltalk.AFICssEditor.klass); - smalltalk.addMethod( "_open", smalltalk.method({ selector: "open", -fn: function (){ +fn: function(){ var self=this; -(($receiver = self['@current']) == nil || $receiver == undefined) ? (function(){(self['@current']=smalltalk.send(self, "_new", []));return smalltalk.send(self['@current'], "_open", []);})() : $receiver; -return self['@current']; -return self;} +smalltalk.send(smalltalk.send(self,"_current",[]),"_open",[]); +return self["@current"]; +} }), smalltalk.AFICssEditor.klass); diff --git a/amber/afi/js/AFI-OPAC.js b/amber/afi/js/AFI-OPAC.js index 83e67fedddcc23d86697ca4f793cd42114fb4a31..c531953cbe46631917f844faa47b79717191eb89 100755 --- a/amber/afi/js/AFI-OPAC.js +++ b/amber/afi/js/AFI-OPAC.js @@ -66,15 +66,19 @@ smalltalk.addMethod( smalltalk.method({ selector: "cssUrl", category: 'accessor', -fn: function (){ +fn: function(){ var self=this; -return (($receiver = self['@cssUrl']) == nil || $receiver == undefined) ? (function(){var linkTag=nil; -(linkTag=smalltalk.send((typeof window == 'undefined' ? nil : window), "_jQuery_", [unescape("%23profil_css")]));(self['@cssUrl']=smalltalk.send(linkTag, "_attr_", ["href"]));smalltalk.send(linkTag, "_remove", []);return self['@cssUrl'];})() : $receiver; -return self;}, +var linkTag; +linkTag=smalltalk.send(window,"_jQuery_",["#profil_css"]); +self["@cssUrl"]=smalltalk.send(linkTag,"_attr_",["data-url"]); +self["@cssUrl"]=smalltalk.send(self["@cssUrl"],"__comma",["?"]); +self["@cssUrl"]=smalltalk.send(self["@cssUrl"],"__comma",[smalltalk.send(smalltalk.send((smalltalk.Date || Date),"_now",[]),"_asMilliseconds",[])]); +return self["@cssUrl"]; +}, args: [], -source: "cssUrl\x0a\x09^ cssUrl ifNil: [\x09|linkTag| \x0a\x09\x09\x09\x09 \x09linkTag := (window jQuery: '#profil_css'). \x0a\x09\x09\x09\x09 \x09cssUrl := linkTag attr: 'href'.\x0a\x09\x09\x09\x09\x09linkTag remove.\x0a\x09\x09\x09\x09\x09cssUrl ]", -messageSends: ["ifNil:", "jQuery:", "attr:", "remove"], -referencedClasses: [] +source: "cssUrl\x0a\x09|linkTag|\x0a\x09linkTag := (window jQuery: '#profil_css').\x0a cssUrl := linkTag attr: 'data-url'.\x09\x0a cssUrl := cssUrl, '?'.\x0a cssUrl := cssUrl, Date now asMilliseconds.\x0a ^ cssUrl.", +messageSends: ["jQuery:", "attr:", ",", "asMilliseconds", "now"], +referencedClasses: ["Date"] }), smalltalk.AFICssEditor); @@ -99,13 +103,25 @@ smalltalk.addMethod( smalltalk.method({ selector: "loadCss", category: 'actions', -fn: function (){ +fn: function(){ var self=this; -(($receiver = smalltalk.send(self, "_cssUrl", [])) != nil && $receiver != undefined) ? (function(){return (function($rec){smalltalk.send($rec, "_onSuccessDo_", [(function(data){smalltalk.send(self, "_contents_", [data]);return smalltalk.send(self, "_updateStyleTag", []);})]);return smalltalk.send($rec, "_send", []);})(smalltalk.send((smalltalk.Ajax || Ajax), "_url_", [self['@cssUrl']]));})() : nil; -return self;}, +var $1,$2,$3; +$1=smalltalk.send(self,"_cssUrl",[]); +if(($receiver = $1) == nil || $receiver == undefined){ +$1; +} else { +$2=smalltalk.send((smalltalk.Ajax || Ajax),"_url_",[self["@cssUrl"]]); +smalltalk.send($2,"_onSuccessDo_",[(function(data){ +smalltalk.send(self,"_contents_",[data]); +return smalltalk.send(self,"_updateStyleTag",[]); +})]); +$3=smalltalk.send($2,"_send",[]); +$3; +}; +return self}, args: [], source: "loadCss\x0a\x09self cssUrl ifNotNil: [\x09(Ajax url: cssUrl) \x0a\x09\x09\x09\x09\x09\x09onSuccessDo: [:data | \x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09self contents: data. \x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09 self updateStyleTag ];\x0a\x09\x09\x09\x09\x09\x09send. ].", -messageSends: ["ifNotNil:", "cssUrl", "onSuccessDo:", "contents:", "updateStyleTag", "send", "url:"], +messageSends: ["ifNotNil:", "onSuccessDo:", "contents:", "updateStyleTag", "url:", "send", "cssUrl"], referencedClasses: ["Ajax"] }), smalltalk.AFICssEditor); @@ -201,12 +217,18 @@ smalltalk.addMethod( smalltalk.method({ selector: "close", category: 'not yet classified', -fn: function (){ +fn: function(){ var self=this; -(($receiver = self['@current']) != nil && $receiver != undefined) ? (function(){smalltalk.send(self['@current'], "_close", []);return (self['@current']=nil);})() : nil; -return self;}, +if(($receiver = self["@current"]) == nil || $receiver == undefined){ +self["@current"]; +} else { +smalltalk.send(self["@current"],"_close",[]); +self["@current"]=nil; +self["@current"]; +}; +return self}, args: [], -source: "close\x0a\x09current\x0a\x09\x09 ifNotNil: [\x09current close.\x0a\x09\x09\x09\x09\x09current := nil ].", +source: "close\x0a\x09current\x0a\x09\x09 ifNotNil: [ current close.\x0a\x09\x09\x09\x09\x09\x09 current := nil ].", messageSends: ["ifNotNil:", "close"], referencedClasses: [] }), @@ -228,40 +250,19 @@ referencedClasses: [] }), smalltalk.AFICssEditor.klass); -smalltalk.addMethod( -"_initializeold", -smalltalk.method({ -selector: "initializeold", -category: 'not yet classified', -fn: function (){ -var self=this; -smalltalk.send(smalltalk.send((smalltalk.AFIIDETools || AFIIDETools),"_default",[]),"_addButton_action_",["Editeur CSS",(function(){ -smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.TabManager || TabManager),"_current",[]),"_tabs",[]),"_do_",[(function(aTab){ -return smalltalk.send(smalltalk.send((smalltalk.TabManager || TabManager),"_current",[]),"_removeTab_",[aTab]); -})]); -return smalltalk.send(smalltalk.send(self,"_current",[]),"_open",[]); -})]); -return self}, -args: [], -source: "initializeold\x0a\x09AFIIDETools default addButton: 'Editeur CSS' action: [\x0a\x09\x09\x09TabManager current tabs do: [:aTab| TabManager current removeTab: aTab].\x0a\x09\x09\x09self current open].", -messageSends: ["addButton:action:", "do:", "removeTab:", "current", "tabs", "open", "default"], -referencedClasses: ["TabManager", "AFIIDETools"] -}), -smalltalk.AFICssEditor.klass); - smalltalk.addMethod( "_open", smalltalk.method({ selector: "open", category: 'not yet classified', -fn: function (){ +fn: function(){ var self=this; -(($receiver = self['@current']) == nil || $receiver == undefined) ? (function(){(self['@current']=smalltalk.send(self, "_new", []));return smalltalk.send(self['@current'], "_open", []);})() : $receiver; -return self['@current']; -return self;}, +smalltalk.send(smalltalk.send(self,"_current",[]),"_open",[]); +return self["@current"]; +}, args: [], -source: "open\x0a\x09current\x0a\x09\x09 ifNil: [\x09current := self new.\x0a\x09\x09\x09\x09current open ].\x0a\x09^ current", -messageSends: ["ifNil:", "new", "open"], +source: "open\x0a\x09self current open.\x0a\x09^ current", +messageSends: ["open", "current"], referencedClasses: [] }), smalltalk.AFICssEditor.klass); diff --git a/amber/afi/st/AFI-OPAC.st b/amber/afi/st/AFI-OPAC.st index 872db47d5a2b4ff93f4158dd6da93b9c3b6ea1b0..f43616393477cefc3610b04dd188bc7082c19789 100755 --- a/amber/afi/st/AFI-OPAC.st +++ b/amber/afi/st/AFI-OPAC.st @@ -14,11 +14,12 @@ contents: aString ! cssUrl - ^ cssUrl ifNil: [ |linkTag| - linkTag := (window jQuery: '#profil_css'). - cssUrl := linkTag attr: 'href'. - linkTag remove. - cssUrl ] + |linkTag| + linkTag := (window jQuery: '#profil_css'). + cssUrl := linkTag attr: 'data-url'. + cssUrl := cssUrl, '?'. + cssUrl := cssUrl, Date now asMilliseconds. + ^ cssUrl. ! label @@ -91,24 +92,16 @@ AFICssEditor class instanceVariableNames: 'current'! close current - ifNotNil: [ current close. - current := nil ]. + ifNotNil: [ current close. + current := nil ]. ! current ^current ifNil: [current := self new] ! -initializeold - AFIIDETools default addButton: 'Editeur CSS' action: [ - TabManager current tabs do: [:aTab| TabManager current removeTab: aTab]. - self current open]. -! - open - current - ifNil: [ current := self new. - current open ]. + self current open. ^ current ! ! diff --git a/application/modules/opac/views/scripts/head.phtml b/application/modules/opac/views/scripts/head.phtml index 11d1a63f5f10959860f36ce174ba7143a0813715..a5069bf7a7b38c00e8b136a04b1b74b440eb5345 100644 --- a/application/modules/opac/views/scripts/head.phtml +++ b/application/modules/opac/views/scripts/head.phtml @@ -61,14 +61,17 @@ if ($this->header_css && ($current_profil->getUseParentCss() || !$current_profil->hasParentProfil()) && !$current_profil->hasPageCss()) $head_scripts->addStyleSheet($this->header_css, ['id' => 'profil_css', + 'data-url' => $current_profil->getHeaderCss(), 'media' => 'all']); if ($this->header_css && $current_profil->getUseParentCss() && $current_profil->hasPageCss()) $head_scripts->addStyleSheet($this->header_css); if($current_profil->hasPageCss()) - $head_scripts->addStyleSheet($current_profil->getPageCss(), ['id' => 'profil_css', - 'media' => 'all']); + $head_scripts->addStyleSheet($current_profil->getPageCss(), + ['id' => 'profil_css', + 'data-url' => $current_profil->getPageCss(), + 'media' => 'all']); if ($this->accessibilite_on) { //Feuilles de styles pour les déficiences visuelles diff --git a/cosmogramme/cosmozend/tests/CosmoControllerTestCase.php b/cosmogramme/cosmozend/tests/CosmoControllerTestCase.php index d9331fa8a8dbcabdb22e46772fbe58b11e815353..c8e88a8fc2350894745d08fee232eba1cbc27650 100644 --- a/cosmogramme/cosmozend/tests/CosmoControllerTestCase.php +++ b/cosmogramme/cosmozend/tests/CosmoControllerTestCase.php @@ -46,6 +46,7 @@ abstract class CosmoControllerTestCase extends Zend_Test_PHPUnit_ControllerTestC Storm_Model_Abstract::unsetLoaders(); Class_FileManager::reset(); Class_FileManager_FileSystem::reset(); + Class_Cosmogramme_LandingDirectory::reset(); } diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php index eb6fde315fd409ff3a028d80b212280b4657bd75..7481b7081e811064c931f819a4d979ad68f8d5a8 100644 --- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php @@ -619,45 +619,90 @@ abstract class Cosmo_IntegrationControllerWaitingFilesTestCase extends CosmoCont 'nom_fichier' => 'lunel/[DATE]_records_tot.mrc', 'taille_min_import_total' => 0]); - $lunel = $this->mock()->whenCalled('getPath') - ->answers('/ccpl34/lunel') - ->whenCalled('getName')->answers('lunel'); - - $this->_tot = $this->mock() - ->whenCalled('getParent')->answers($lunel) - ->whenCalled('isWritable')->answers(true) - ->whenCalled('getName')->answers('20190116220001_records_tot.mrc') - ->whenCalled('getMTime')->answers('2019-01-13 22:88:77') - ->whenCalled('getSize')->answers('42 Ko') - ->whenCalled('getFileSize')->answers(43986) - ->whenCalled('getId')->answers('/ccpl34/lunel/20190116220001_records_tot.mrc') - ->whenCalled('getModels')->answers([]) - ->whenCalled('isDir')->answers(false) - ->whenCalled('getPath')->answers('/ccpl34/lunel/') - ->whenCalled('readfile')->answers(true) - ->whenCalled('getProgrammed')->answers(Class_IntMajAuto::find(43)) - ; + $ccpl34 = $this + ->mock() + ->whenCalled('isDir')->answers(true) + ->whenCalled('getPath')->answers('/ccpl34') + ->whenCalled('getName')->answers('ccpl34'); + + $lunel = $this + ->mock() + ->whenCalled('isDir')->answers(true) + ->whenCalled('getPath')->answers('/ccpl34/lunel') + ->whenCalled('getName')->answers('lunel') + ->whenCalled('getParent')->answers($ccpl34); + + $etalon = $this + ->mock() + ->whenCalled('isDir')->answers(true) + ->whenCalled('getPath')->answers('/ccpl34/etalon') + ->whenCalled('getName')->answers('etalon') + ->whenCalled('getParent')->answers($ccpl34); + + $kinds = $this + ->mock() + ->whenCalled('getName')->answers('genres.txt') + ->whenCalled('getMTime')->answers('2019-01-13 22:88:77') + ->whenCalled('getFileSize')->answers(43986) + ->whenCalled('getParent')->answers($etalon) + ->whenCalled('getPath')->answers('/ccpl34/etalon/genres.txt') + ->whenCalled('getFileMTime')->answers('12345678') + ->whenCalled('getProgrammed')->answers(null) + ->whenCalled('isWritable')->answers(true) + ->whenCalled('getId')->answers('/ccpl34/etalon/genres.txt') + ->whenCalled('getParentPath')->answers('/ccpl34/etalon') + ->whenCalled('isFile')->answers(true); + + $this->_tot = $this + ->mock() + ->whenCalled('getParent')->answers($lunel) + ->whenCalled('isWritable')->answers(true) + ->whenCalled('getName')->answers('20190116220001_records_tot.mrc') + ->whenCalled('getMTime')->answers('2019-01-13 22:88:77') + ->whenCalled('getFileMTime')->answers('1234567') + ->whenCalled('getSize')->answers('42 Ko') + ->whenCalled('getFileSize')->answers(43986) + ->whenCalled('getId')->answers('/ccpl34/lunel/20190116220001_records_tot.mrc') + ->whenCalled('getModels')->answers([]) + ->whenCalled('isDir')->answers(false) + ->whenCalled('getPath')->answers('/ccpl34/lunel/20190116220001_records_tot.mrc') + ->whenCalled('getParentPath')->answers('/ccpl34/lunel') + ->whenCalled('readfile')->answers(true) + ->whenCalled('getProgrammed')->answers(Class_IntMajAuto::find(43)) + ->whenCalled('isFile')->answers(true); $this->_tot->whenCalled('setProgrammed')->answers($this->_tot); $file_system = $this ->mock() - ->whenCalled('directoriesAt')->with('/ccpl34')->answers([$lunel]) + ->whenCalled('search')->with('*', '/ccpl34/lunel')->answers([$this->_tot]) + + ->whenCalled('search')->with('*', '/ccpl34/etalon')->answers([$kinds]) + + ->whenCalled('directoriesAt')->with('/ccpl34')->answers([$lunel, $etalon]) + + ->whenCalled('directoryAt')->with('ccpl34/lunel')->answers($lunel) + + ->whenCalled('directoryAt')->with('ccpl34/etalon')->answers($etalon) - ->whenCalled('filesAt')->with('/ccpl34/lunel')->answers([$this->_tot]) + ->whenCalled('fileAt')->with('ccpl34/lunel')->answers(null) + + ->whenCalled('fileAt')->with('ccpl34/etalon')->answers(null) + + ->whenCalled('delete')->with('/ccpl34/lunel/20190116220001_records_tot.mrc') + ->answers(true) ->whenCalled('directoryAt')->with('ccpl34/lunel/20190116220001_records_tot.mrc') ->answers(null) ->whenCalled('fileAt')->with('ccpl34/lunel/20190116220001_records_tot.mrc') - ->answers($this->_tot) + ->answers($this->_tot); - ->whenCalled('delete')->with('/ccpl34/lunel/20190116220001_records_tot.mrc') - ->answers(true) - ; Class_FileManager::setFileSystem($file_system); + Class_Cosmogramme_LandingDirectory::setSubdirCache($etalon); + Class_AdminVar::set('NOM_DOMAINE', 'http://localhost'); } } @@ -700,6 +745,12 @@ class Cosmo_IntegrationControllerWaitingFilesActionTest public function linkToDownloadRecordTotShouldBePresent() { $this->assertXPath('//a[@href = "/cosmo/integration/waiting-files-download?id=%2Fccpl34%2Flunel%2F20190116220001_records_tot.mrc"]'); } + + + /** @test */ + public function kindsShouldBeProgrammed() { + $this->assertXPathContentContains('//tr[@data-path="/ccpl34/etalon/genres.txt"]//td', 'Programmé'); + } } diff --git a/cosmogramme/tests/php/classes/ModelTestCase.php b/cosmogramme/tests/php/classes/ModelTestCase.php index 92cf19ee005944c585c3417e29a30295cb0536b1..c34a5d3642afb526c850930122a4ebab9babe1a9 100644 --- a/cosmogramme/tests/php/classes/ModelTestCase.php +++ b/cosmogramme/tests/php/classes/ModelTestCase.php @@ -85,6 +85,8 @@ abstract class ModelTestCase extends PHPUnit_Framework_TestCase { Storm_Model_Loader::defaultToDb(); Storm_Model_Abstract::unsetLoaders(); Class_Crypt::setPhpCommand(null); + Class_Cosmogramme_LandingDirectory::reset(); + Class_Cosmogramme_Generator_KindsTask::setDbAdapter(null); } diff --git a/library/Class/AlbumCategorie.php b/library/Class/AlbumCategorie.php index 457259988257d113f5535595bc422030baf6ecc4..b27da197ad60add2b1378a3045685a64ca627afe 100644 --- a/library/Class/AlbumCategorie.php +++ b/library/Class/AlbumCategorie.php @@ -269,4 +269,14 @@ class Class_AlbumCategorie extends Storm_Model_Abstract { 'categories' => $this->getAlbumsInfosForTree($this->getSousCategories()), 'items' => []]; } + + + public function getSousCategoriesIds($ids = []) { + $ids [] = $this->getId(); + + foreach ($this->getSousCategories() as $sous_categorie) + $ids = $sous_categorie->getSousCategoriesIds($ids); + + return $ids; + } } \ No newline at end of file diff --git a/library/Class/AlbumCategorie/Remover.php b/library/Class/AlbumCategorie/Remover.php new file mode 100644 index 0000000000000000000000000000000000000000..a58473a6dfb8b66141109001d5bf4886bdd6f1f7 --- /dev/null +++ b/library/Class/AlbumCategorie/Remover.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_AlbumCategorie_Remover extends Class_Entity { + + use Trait_StaticCommand; + + public function run() { + $command = sprintf('delete_album_category.php %s >/dev/null 2>&1 &', + escapeshellarg($this->getId())); + $this->getCommand()->execTimedScript(3600, $command); + return $this; + } +} diff --git a/library/Class/CodifGenre.php b/library/Class/CodifGenre.php index 60d5274529484bcf37c5da39155cc6af885c8fe7..7c97109ff916365a6b988fe9c34f76c8d0f6f160 100644 --- a/library/Class/CodifGenre.php +++ b/library/Class/CodifGenre.php @@ -47,6 +47,8 @@ class Class_CodifGenre extends Storm_Model_Abstract { $_loader_class = 'Class_CodifGenreLoader', $_table_name = 'codif_genre', $_table_primary = 'id_genre', - $_default_attribute_values = ['picto' => '']; + $_default_attribute_values = ['picto' => '', + 'libelle' => '', + 'regles' => '', + 'date_maj' => '']; } -?> diff --git a/library/Class/Cosmogramme/Generator.php b/library/Class/Cosmogramme/Generator.php index 39e8774e8eafe695c1428c6e838758db61a92a26..52aa6f6875352726ce62c2756f5474707b1f10a4 100644 --- a/library/Class/Cosmogramme/Generator.php +++ b/library/Class/Cosmogramme/Generator.php @@ -66,11 +66,21 @@ class Class_Cosmogramme_Generator { public function getUpdatableStandard() { - if (null === Class_IntMajAuto::findFirstBy([]) - || !Class_IntBib::isSingleNanook()) + if (null === Class_IntMajAuto::findFirstBy([])) { + $this->logError($this->_('Aucune intégration programmée.')); return null; + } + + if (!Class_IntBib::isSingleNanook()) { + $this->logError($this->_('Le mode Nanook unique n\'est pas activé.')); + return null; + } + + $landing_directory = $this->getLandingDirectory(); + if (!$result = $landing_directory->getUpdatableStandard()) + $this->logError($landing_directory->getLog()->getLastMessage()); - return $this->getLandingDirectory()->getUpdatableStandard(); + return $result; } diff --git a/library/Class/Cosmogramme/Generator/AbstractTask.php b/library/Class/Cosmogramme/Generator/AbstractTask.php index 168006e6c31fe43e3b85261e9eabfc7bc5389aca..ca88a3596497dc07ab3117a36e36018e61e35782 100644 --- a/library/Class/Cosmogramme/Generator/AbstractTask.php +++ b/library/Class/Cosmogramme/Generator/AbstractTask.php @@ -98,8 +98,9 @@ abstract class Class_Cosmogramme_Generator_AbstractTask { $model = $model_class::newInstance(['libelle' => $label]); return - $model->setDateMaj($this->_date) - ->setRegles($this->_createOrConcatRules($code, $model)); + $model + ->setRegles($this->_createOrConcatRules($code, $model)) + ->setDateMaj($this->_date); } diff --git a/library/Class/Cosmogramme/Generator/KindsTask.php b/library/Class/Cosmogramme/Generator/KindsTask.php index 955b3e7e5caaef8db161edd188202ebe942d0b5f..7a8a7ae78a17a41fa67bc72f358ee0b7afd15d75 100644 --- a/library/Class/Cosmogramme/Generator/KindsTask.php +++ b/library/Class/Cosmogramme/Generator/KindsTask.php @@ -57,4 +57,18 @@ class Class_Cosmogramme_Generator_KindsTask extends Class_Cosmogramme_Generator_ protected function getItemField() { return 'genre'; } + + + protected function _findExistingBy($code, $label) { + return ($model = Class_CodifGenre::findFirstBy(['libelle' => $label])) + ? $model + : Class_CodifGenre::newInstance(['libelle' => $label]); + } + + + protected function _createOrConcatRules($code, $model) { + return $this->_date != $model->getDateMaj() + ? $this->_getRuleFor($code) + : $this->_concatRulesTo($code, $model); + } } diff --git a/library/Class/Cosmogramme/Integration/PhasePrepareIntegrations.php b/library/Class/Cosmogramme/Integration/PhasePrepareIntegrations.php index 2836fe1805b724936f63e1212e564cfc2a7bc999..8e2aca10addc9572f7d22274d0973bf70673513f 100644 --- a/library/Class/Cosmogramme/Integration/PhasePrepareIntegrations.php +++ b/library/Class/Cosmogramme/Integration/PhasePrepareIntegrations.php @@ -70,10 +70,13 @@ class Class_Cosmogramme_Integration_PhasePrepareIntegrations extends Class_Cosmo protected function _updateStandard() { $generator = (new Class_Cosmogramme_Generator())->beUpdate(); - if (!$standard_dir = $generator->getUpdatableStandard()) + $this->_log->log('<h4>' . $this->_('Mise à jour de l\'étalon') . '</h4>'); + + if (!$standard_dir = $generator->getUpdatableStandard()) { + $this->_log->info($this->_('État de la Configuration : %s', $generator->getLastError())); return $this; + } - $this->_log->log('<h4>' . $this->_('Mise à jour de l\'étalon') . '</h4>'); $generator->update($standard_dir) ? $this->_log->success($this->_('OK')) : $this->_log->error($this->_('Erreur : %s', diff --git a/library/Class/Cosmogramme/Integration/WaitingFiles.php b/library/Class/Cosmogramme/Integration/WaitingFiles.php index fd921d81b982ce85a140b31c82c4bd917f15744a..cd5bf8a667ce7a9bcf22b014c7874b76cbf50fb3 100644 --- a/library/Class/Cosmogramme/Integration/WaitingFiles.php +++ b/library/Class/Cosmogramme/Integration/WaitingFiles.php @@ -26,9 +26,11 @@ class Class_Cosmogramme_Integration_WaitingFiles { Class_FileManager_FileSystem::beUnlimited(); $files = []; + foreach(Class_FileManager::directories(Class_CosmoVar::get('ftp_path')) as $directory) - foreach(Class_FileManager::files($directory->getPath()) as $file) - $files[] = $file; + foreach(Class_FileManager::search('*', $directory->getPath()) as $file) + if ($file->isFile()) + $files[] = $file; usort($files, function($a, $b) diff --git a/library/Class/Cosmogramme/LandingDirectory.php b/library/Class/Cosmogramme/LandingDirectory.php index 50c51c2a19ca717583aa9b9f492b2b37cc45d146..bdc24c20eed4e8b37b092e0a6387f8d97d89052a 100644 --- a/library/Class/Cosmogramme/LandingDirectory.php +++ b/library/Class/Cosmogramme/LandingDirectory.php @@ -26,6 +26,8 @@ class Class_Cosmogramme_LandingDirectory { const VAR_NAME = 'ftp_path'; const STANDARD_NAME = 'etalon'; + protected static $_subdir_cache; + protected $_path, $_required_files = ['libraries' => 'annexes.txt', @@ -39,6 +41,22 @@ class Class_Cosmogramme_LandingDirectory { } + public static function reset() { + static::$_subdir_cache = null; + static::setInstance(null); + } + + + public static function setSubdirCache($subdir) { + static::$_subdir_cache = $subdir; + } + + + public function getRequiredFiles() { + return $this->_required_files; + } + + public function isValid() { if ($this->_path && $this->getFileSystem()->file_exists($this->_path)) return true; @@ -78,9 +96,12 @@ class Class_Cosmogramme_LandingDirectory { public function getUpdatableStandard() { + if (static::$_subdir_cache) + return static::$_subdir_cache; + if (($subdir = $this->getSingleSubdirectory()) && $this->couldGenerateFrom($subdir)) - return $subdir; + return static::$_subdir_cache = $subdir; } @@ -151,9 +172,18 @@ class Class_Cosmogramme_LandingDirectory { public function getSingleSubdirectory() { - if (!$subdirs = $this->getSubdirectories()) + if (!$subdirs = $this->getSubdirectories()) { + $this->log($this->_('Pas de sous-répertoire dans : %s', + $this->_path)); return null; + } + + if ( 1 < count($subdirs)) { + $this->log($this->_('Trop de sous-répertoires dans : %s', + $this->_path)); + return null; + } - return 1 == count($subdirs) ? current($subdirs) : null; + return current($subdirs); } } \ No newline at end of file diff --git a/library/Class/FileManager/FileSystem.php b/library/Class/FileManager/FileSystem.php index 120d2a4d19418f350371ff1c2d7b6e78d2ae2b2d..54ab9c32be33c73bee4fc4b4c941cc18381c30b8 100644 --- a/library/Class/FileManager/FileSystem.php +++ b/library/Class/FileManager/FileSystem.php @@ -367,7 +367,7 @@ class Class_FileManager_FileSystem { sort($found, SORT_NATURAL); - if(Class_FileManager_FileSystem::LISTING_LIMIT < count($found)) { + if(static::$_limited && Class_FileManager_FileSystem::LISTING_LIMIT < count($found)) { $this->_oversized[] = $path; $found = array_slice($found, 0, Class_FileManager_FileSystem::LISTING_LIMIT); } diff --git a/library/Class/TableDescription/CosmoWaitingFiles.php b/library/Class/TableDescription/CosmoWaitingFiles.php index c17e34f3461dbe33303704920d2986ced041de54..c27b6bcf675891ed18d1ba790831f09e0793411b 100644 --- a/library/Class/TableDescription/CosmoWaitingFiles.php +++ b/library/Class/TableDescription/CosmoWaitingFiles.php @@ -33,10 +33,33 @@ class Class_TableDescription_CosmoWaitingFiles extends Class_TableDescription { public function read() { - $statut = function($item) { + $landing_directory = new Class_Cosmogramme_LandingDirectory; + + $standard_status = function($item) use ($landing_directory) { + if (!$landing_directory->getUpdatableStandard()) + return $this->_view->tagWarning($this->_('Non programmé')); + + return in_array($item->getName(), $landing_directory->getRequiredFiles()) + ? $this->_view->tagNotice($this->_('Programmé')) + : $this->_view->tagWarning($this->_('Non programmé')); + }; + + $statut = function($item) use ($standard_status) { $folder = ($parent = $item->getParent()) ? $parent->getName() : ''; + $path = $folder . '/' . $item->getName(); + + if ($folder == Class_Cosmogramme_LandingDirectory::STANDARD_NAME) + return $standard_status($item); + + $higher_folder = ($higher_parent = $parent->getParent()) ? $higher_parent->getName() : ''; + $higher_path = $higher_folder ? $higher_folder . '/' . $path : ''; + + if ($prog = Class_IntMajAuto::findFirstby(['nom_fichier' => $path])) { + $item->setProgrammed($prog); + return $this->_view->tagNotice($this->_('Programmé')); + } - if ($prog = Class_IntMajAuto::findFirstby(['nom_fichier' => $folder . '/' . $item->getName()])) { + if ($higher_path && $prog = Class_IntMajAuto::findFirstby(['nom_fichier' => $higher_path])) { $item->setProgrammed($prog); return $this->_view->tagNotice($this->_('Programmé')); } @@ -93,7 +116,15 @@ class Class_TableDescription_CosmoWaitingFiles extends Class_TableDescription { $this ->addColumn($this->_('Dossier'), - function($item) { return ($parent = $item->getParent()) ? $parent->getName() : ''; }) + ['callback' => function($item) + { + return ($parent = $item->getParent()) ? $item->getParentPath() : ''; + }, + 'options' => ['row_params' => function($item) + { + return ['data-path' => $item->getPath()]; + } + ]]) ->addColumn($this->_('Fichier'), function($item) { return $item->getName(); }) @@ -136,8 +167,7 @@ class Class_TableDescription_CosmoWaitingFiles extends Class_TableDescription { ->addRowAction($delete) - ->addRowAction($download) - ; + ->addRowAction($download); return $this; } diff --git a/library/ZendAfi/Controller/Plugin/Manager/Album.php b/library/ZendAfi/Controller/Plugin/Manager/Album.php index d61c405111bed28529e84efa3ffea250877cef5c..cbb6d598b135ca996c923ede5ce23146b22be949 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/Album.php +++ b/library/ZendAfi/Controller/Plugin/Manager/Album.php @@ -57,8 +57,13 @@ class ZendAfi_Controller_Plugin_Manager_Album extends ZendAfi_Controller_Plugin_ public function deletecategorieAction() { - if ($categorie = Class_AlbumCategorie::find((int)$this->_getParam('id'))) - $categorie->delete(); + if (!$category = Class_AlbumCategorie::find((int)$this->_getParam('id'))) + $this->_redirect('admin/album'); + + $this->_helper->notify($this->_('La suppression de la catégorie %s a bien été prise en compte.', + $category->getLibelle())); + + (new Class_AlbumCategorie_Remover(['Id' => $category->getId()]))->run(); $this->_redirect('admin/album'); } diff --git a/scripts/delete_album_category.php b/scripts/delete_album_category.php new file mode 100644 index 0000000000000000000000000000000000000000..ce94d558112eaf387737e417797b3690b50794aa --- /dev/null +++ b/scripts/delete_album_category.php @@ -0,0 +1,16 @@ +<?php +require(__DIR__.'/../console.php'); + +$id = $argv[1]; + +if (!$category = Class_AlbumCategorie::find($id)) + exit(1); + +while ($albums = Class_Album::findAllBy(['cat_id' => $category->getSousCategoriesIds(), + 'limit' => 500])) { + array_map(function($album) { $album->delete();}, $albums); + Class_Album::clearCache(); +} + +$category->delete(); +?> \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/AlbumControllerTest.php b/tests/application/modules/admin/controllers/AlbumControllerTest.php index c31ce32943db5f891790aa1e3f426f44b125e6bd..e8fc2acf476627f17812c13ef960a278e9800ef7 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerTest.php @@ -46,13 +46,6 @@ abstract class Admin_AlbumControllerTestCase extends Admin_AbstractControllerTes ->whenCalled('findAllBy') ->answers([$cus, $fre, $dak]); - $favoris = $this->fixture('Class_AlbumCategorie', ['id' => 2]) - ->setParentId(0) - ->setLibelle('Favoris') - ->setSousCategories([]) - ->setAlbums([]); - $favoris->save(); - $adulte = $this->fixture('Class_AlbumCategorie', ['id' => 6]) ->setLibelle('Adulte') ->setParentId(2) @@ -60,6 +53,13 @@ abstract class Admin_AlbumControllerTestCase extends Admin_AbstractControllerTes ->setAlbums([]); $adulte->save(); + $favoris = $this->fixture('Class_AlbumCategorie', ['id' => 2]) + ->setParentId(0) + ->setLibelle('Favoris') + ->setSousCategories([$adulte]) + ->setAlbums([]); + $favoris->save(); + $patrimoine = $this->fixture('Class_AlbumCategorie', ['id' => 38]) ->setParentId(0) ->setSousCategories([]) @@ -541,16 +541,34 @@ class Admin_AlbumControllerEditCategorieFavorisTest extends Admin_AlbumControlle class Admin_AlbumControllerDeleteCategorieFavorisTest extends Admin_AlbumControllerTestCase { public function setUp() { parent::setUp(); + + $command = $this + ->mock()->beStrict() + ->whenCalled('execTimedScript') + ->with(3600, 'delete_album_category.php \'2\' >/dev/null 2>&1 &') + ->willDo(function() + { + Class_AlbumCategorie::find(2)->delete(); + Class_AlbumCategorie::clearCache(); + }); + + Class_AlbumCategorie_Remover::setCommand($command); + $this->dispatch('/admin/album/delete_categorie/id/2'); } - /** @test */ - public function deleteShouldHaveBeenCalledOnFavoris() { + public function categoryFavorisShouldHaveBeenDeleted() { $this->assertNull(Class_AlbumCategorie::findFirstBy(['libelle'=>'Favoris'])); } + /** @test */ + public function adulteShouldHaveBeenDeleted() { + $this->assertNull(Class_AlbumCategorie::findFirstBy(['libelle'=>'Adulte'])); + } + + /** @test */ public function shouldRedirectToIndex() { $this->assertRedirectTo('/admin/album'); diff --git a/tests/application/modules/opac/controllers/IndexControllerTest.php b/tests/application/modules/opac/controllers/IndexControllerTest.php index 3897d5fc2a3e7a13756ee50f7514431fbac2e44b..9b090e54950e46b9927e67daf2973aa8246fb953 100644 --- a/tests/application/modules/opac/controllers/IndexControllerTest.php +++ b/tests/application/modules/opac/controllers/IndexControllerTest.php @@ -179,7 +179,7 @@ class IndexControllerAsAdminWithCSSEditorTest extends IndexControllerAsAdminTest /** @test */ public function headerCssShouldBeMyCssWithCacheWorkaround() { - $this->assertXPath('//link[contains(@href, "mycss.css")][contains(@href, "?cache=")]'); + $this->assertXPath('//link[contains(@href, "mycss.css")][contains(@href, "?cache=")][@data-url= "mycss.css"]'); } } diff --git a/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php b/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php index a3c3f28f6720444fb5289c45b7a0ce7ddd73708b..1c4682b391f31b93828416d8fd2b16380765df5c 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php @@ -30,11 +30,13 @@ abstract class PhasePrepareIntegrationsWithOAITestCase $foo = $this->mock() ->whenCalled('getName')->answers('foo') + ->whenCalled('isDir')->answers(true) ->whenCalled('getPath')->answers('ftp/my-library.net/transferts/foo'); $file_with_date = $this->mock() ->whenCalled('getName')->answers('20180517mylibraryincr.txt') + ->whenCalled('isFile')->answers(true) ->whenCalled('getId')->answers('ftp/my-library.net/transferts/foo/20180517mylibraryincr.txt') ->whenCalled('getFileMTime')->answers(strtotime('2018-05-17')) ->whenCalled('getParent')->answers($foo); @@ -42,6 +44,7 @@ abstract class PhasePrepareIntegrationsWithOAITestCase $other_with_date = $this->mock() ->whenCalled('getName')->answers('20190118mylibraryincr.txt') + ->whenCalled('isFile')->answers(true) ->whenCalled('getId')->answers('ftp/my-library.net/transferts/foo/20190118mylibraryincr.txt') ->whenCalled('getFileMTime')->answers(strtotime('2019-01-18')) ->whenCalled('getParent')->answers($foo); @@ -53,7 +56,10 @@ abstract class PhasePrepareIntegrationsWithOAITestCase ->whenCalled('directoriesAt')->with('ftp/my-library.net/transferts/') ->answers([$foo]) - ->whenCalled('filesAt')->with('ftp/my-library.net/transferts/foo') + ->whenCalled('directoryAt')->with('ftp/my-library.net/transferts/foo') + ->answers($foo) + + ->whenCalled('search')->with('*', 'ftp/my-library.net/transferts/foo') ->answers([$file_with_date, $other_with_date]); @@ -123,7 +129,6 @@ abstract class PhasePrepareIntegrationsWithOAITestCase Class_Cosmogramme_Integration_PhasePrepareIntegrations::setFileSystem($file_system); Class_Cosmogramme_Integration_PhasePrepareIntegrations::setTimeSource(new TimeSourceForTest('2015-03-26 14:00:00')); - $this->_phase = $this->_buildPhase('PrepareIntegrations')->run(); } @@ -457,7 +462,6 @@ class PhasePrepareIntegrationsNanookStandardTest Class_Cosmogramme_LandingDirectory::setInstance($landing_directory); - $this->fixture('Class_CodifSection', ['id' => 34, 'libelle' => 'Game', @@ -600,9 +604,7 @@ class PhasePrepareIntegrationsNanookStandardTest 'id_article_periodique' => Class_IntProfilDonnees::SERIAL_FORMAT_PERGAME, 'type_fichier' => Class_IntProfilDonnees::FT_RECORDS, 'format' => Class_IntProfilDonnees::FORMAT_UNIMARC, - 'attributs' => [] - ] - ); + 'attributs' => []]); $this->fixture('Class_IntProfilDonnees', ['id' => 103, @@ -800,4 +802,157 @@ class PhasePrepareIntegrationsNanookStandardTest public function renamedSectionShouldBeUpdated() { $this->assertEquals('Jeunes', Class_CodifSection::find(38)->getLibelle()); } +} + + + +class PhasePrepareIntegrationsKindTest extends Class_Cosmogramme_Integration_PhaseTestCase { + protected $_http_client; + + public function setUp() { + parent::setUp(); + + Class_Cosmogramme_Generator_KindsTask::setTimeSource(new TimeSourceForTest('2019-02-12 14:00:00')); + + $sql = $this + ->mock() + ->beStrict() + + ->whenCalled('query') + ->with('update exemplaires set genre="" where genre="5"') + ->answers('') + + ->whenCalled('query') + ->with('update exemplaires set genre="" where genre="4"') + ->answers('') + + ->whenCalled('query') + ->with('update notices set date_maj="2019-02-12 14:00:00" where match(facettes) against("G4 G5" in BOOLEAN MODE)') + ->answers('') + + ->whenCalled('query') + ->with('delete from codif_genre where date_maj != "2019-02-12"') + ->willDo(function() + { + (new Storm_Model_Collection(Class_CodifGenre::findAllBy(['date_maj not' => '2019-02-12']))) + ->eachDo('delete'); + }) + + ->whenCalled('query') + ->with('update codif_genre set date_maj=""') + ->willDo(function() + { + (new Storm_Model_Collection(Class_CodifGenre::findAll())) + ->eachDo(function($model) + { + $model->setDateMaj(''); + }); + }); + + Class_Cosmogramme_Generator_KindsTask::setDbAdapter($sql); + + $generator = $this + ->mock() + + ->whenCalled('logTitle') + ->answers('') + + ->whenCalled('log') + ->answers('') + + ->whenCalled('isNanook') + ->answers(true) + + ->whenCalled('isPergame') + ->answers(false); + + $this->fixture('Class_CodifGenre', + ['id' => 4, + 'libelle' => 'ALBUM', + 'regles' => '995$7=1']); + + $this->fixture('Class_CodifGenre', + ['id' => 5, + 'libelle' => 'Fiction', + 'regles' => '995$7=3']); + + $this->fixture('Class_CodifGenre', + ['id' => 6, + 'libelle' => 'SYNTHETISEUR, flûte de PAN', + 'regles' => '995$7=51;2;3']); + + $datas = ['BIB_GENRES|SUPPORT|CODE|LIBELLE|DOC', + '0|1|Music|f', + '0|2|Bande dessinée|f', + '0|3|Bande dessinée|f', + '0|51|SYNTHETISEUR, flûte de PAN|f', + '0|94|SYNTHETISEUR|f']; + + (new Class_Cosmogramme_Generator_KindsTask($generator, []))->run($datas); + } + + + /** @test */ + public function fictionShouldHaveBeenDeleted() { + $this->assertNull(Class_CodifGenre::find(34)); + } + + + /** @test */ + public function albumShouldBeDeleted() { + $this->assertNull(Class_CodifGenre::find(4)); + } + + + /** @test */ + public function fourKindsShouldRemains() { + $this->assertEquals(4, Class_CodifGenre::count()); + } + + + public function getAttribs() { + return [ + ['Music', + ['picto' => '', + 'libelle' => 'Music', + 'regles' => '995$7=1', + 'date_maj' => '', + 'id' => 7, + 'id_genre' => 7]], + + ['Bande dessinée', + ['picto' => '', + 'libelle' => 'Bande dessinée', + 'regles' => '995$7=2;3', + 'date_maj' => '', + 'id' => 8, + 'id_genre' => 8]], + + ['SYNTHETISEUR, flûte de PAN', + ['picto' => '', + 'libelle' => 'SYNTHETISEUR, flûte de PAN', + 'regles' => '995$7=51', + 'date_maj' => '', + 'id' => 6, + 'id_genre' => 6]], + + ['SYNTHETISEUR', + ['picto' => '', + 'libelle' => 'SYNTHETISEUR', + 'regles' => '995$7=94', + 'date_maj' => '', + 'id' => 9, + 'id_genre' => 9]] + ]; + } + + + /** + * @dataProvider getAttribs + * @test + */ + public function codifAttribsShouldBeAsExpected($label, $attribs) { + $this->assertNotNull($kind = Class_CodifGenre::findFirstBy(['libelle' => $label])); + $this->assertEquals($attribs, $kind->toArray()); + } } \ No newline at end of file diff --git a/tests/library/Class/Migration/SigbStandardCodificationsTest.php b/tests/library/Class/Migration/SigbStandardCodificationsTest.php index 536e9aa38d062cca2b8c40688311abb4b23f52ef..be940be2ad16039fe7a77af49b31a845282b253f 100644 --- a/tests/library/Class/Migration/SigbStandardCodificationsTest.php +++ b/tests/library/Class/Migration/SigbStandardCodificationsTest.php @@ -100,7 +100,7 @@ class Class_Migration_SigbStandardCodificationsTest extends ModelTestCase { /** @test */ public function withSingleNanookShouldCleanLocations() { (new Class_Migration_SigbStandardCodifications())->run(); - $this->assertEquals('995$6=108;9', Class_CodifEmplacement::find(33)->getRegles()); + $this->assertEquals('995$6=9', Class_CodifEmplacement::find(33)->getRegles()); } diff --git a/tests/library/Class/ModelTestCase.php b/tests/library/Class/ModelTestCase.php index e95f85b7703f0a2ab3b7cdc576ac10071dec57aa..fc600cf475eca4634fd97c2129a68840a607f072 100644 --- a/tests/library/Class/ModelTestCase.php +++ b/tests/library/Class/ModelTestCase.php @@ -99,6 +99,8 @@ abstract class ModelTestCase extends Storm_Test_ModelTestCase { Class_FileManager::reset(); Class_MoteurRecherche::resetInstance(); Class_Crypt::setPhpCommand(null); + Class_Cosmogramme_LandingDirectory::reset(); + Class_Cosmogramme_Generator_KindsTask::setDbAdapter(null); if($this->_storm_default_to_volatile) { Storm_Model_Loader::defaultToDb();