Skip to content
Snippets Groups Projects
Commit 8f2f9be7 authored by efalcy's avatar efalcy
Browse files

hotline 80020:fix deleted numilog harvest

parent dc4f4b2e
Branches
Tags
3 merge requests!2869Master,!2830Hotline,!2826Hotline#80020 moissonnage numilog remonte des notices en statut deleted
Pipeline #4985 failed with stage
in 43 minutes and 36 seconds
- ticket #80020 : Moissonnage Numilog remonte des notices en statut Deleted
\ No newline at end of file
......@@ -29,7 +29,20 @@
*/
class Class_WebService_OAI_DublinCoreParser extends Class_WebService_OAI_ParserAbstract {
protected $_record;
protected $_record,
$_current_is_deleted = false;
public function startHeader($attributes) {
if (!isset($attributes['STATUS']))
return $this->_current_is_deleted = false;
xdebug_break();
if ($attributes['STATUS'] == 'deleted')
return $this->_current_is_deleted = true;
return $this->_current_is_deleted = false;
}
public function endns1_record($data) {
$this->endRecord($data);
......
......@@ -77,6 +77,8 @@ class Class_WebService_OAI_DublinCoreParser_ForRessourceNumerique extends Class_
public function endRecord($data) {
if ($this->_current_is_deleted)
return;
$first_editor = isset($this->_record['editeur'][0])
? $this->_record['editeur'][0]
: '';
......
......@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class NumilogTest extends ModelTestCase {
abstract class AbstractNumilogCatalogueTest extends ModelTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
......@@ -33,18 +33,17 @@ class NumilogTest extends ModelTestCase {
Class_AdminVar::newInstanceWithId('NUMILOG_URL', ['valeur' => 'http://numilog-oai-url']);
Class_AdminVar::newInstanceWithId('NUMILOG_OAI_IDBIB', ['valeur' => '44']);
$catalogue_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/numilog_catalogue.xml');
$catalogue_end_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/numilog_end.xml');
$this->_http_client = $this->mock()
->whenCalled('open_url')
->with('http://numilog-oai-url?verb=ListRecords&metadataPrefix=oai_dc&set=bib%3A44')
->answers($catalogue_xml)
->answers($this->_getXml())
->whenCalled('open_url')
->with('http://numilog-oai-url?verb=ListRecords&resumptionToken=769701498%21500%21oai_dc%21bib%3A44%21')
->answers($catalogue_end_xml)
->beStrict();
$codif_type_doc = $this->fixture('Class_CodifTypeDoc',
......@@ -78,7 +77,7 @@ class NumilogTest extends ModelTestCase {
->whenCalled('execTimedScript')
->answers(''));
Class_WebService_BibNumerique_Numilog::setDefaultHttpClient($this->_http_client);
$this->_numilog->harvest('');
$this->_first_livre_numerique = $this->_numilog->loadPage(1)->getRessourcesNumeriques()[0];
......@@ -87,6 +86,9 @@ class NumilogTest extends ModelTestCase {
$this->_third_album = $this->_numilog->getAlbums()[2];
}
protected function _getXml() {
return file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/numilog_catalogue.xml');
}
public function tearDown() {
Class_WebService_BibNumerique_RessourceNumerique::setCommand(null);
......@@ -94,7 +96,10 @@ class NumilogTest extends ModelTestCase {
parent::tearDown();
}
}
class NumilogCatalogueTest extends AbstractNumilogCatalogueTest {
/**
* @test
*/
......@@ -228,3 +233,18 @@ class NumilogTest extends ModelTestCase {
$this->assertEquals('18;19',$this->_third_album->getSections());
}
}
class NumilogDeletedTest extends AbstractNumilogCatalogueTest {
protected function _getXml() {
return file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/numilog_with_deleted.xml');
}
/** @test */
public function firstAlbumIdOrigineShouldBeDeleted() {
$this->assertNotEquals('9782246804383', $this->_first_album->getIdOrigine());
}
}
\ No newline at end of file
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