diff --git a/VERSIONS_HOTLINE/82189 b/VERSIONS_HOTLINE/82189 new file mode 100644 index 0000000000000000000000000000000000000000..82a581d2734219dc32d414cdaf5354250bb2ea57 --- /dev/null +++ b/VERSIONS_HOTLINE/82189 @@ -0,0 +1 @@ + - ticket #82189 : Connecteur LeKiosk : correction de la mise à jour lors du moissonage \ No newline at end of file diff --git a/cosmogramme/sql/patch/patch_361.php b/cosmogramme/sql/patch/patch_361.php new file mode 100644 index 0000000000000000000000000000000000000000..851cb5cb89f4275b7b95513e0bb9f1512284d325 --- /dev/null +++ b/cosmogramme/sql/patch/patch_361.php @@ -0,0 +1,6 @@ +<?php +$adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); + +try { + $adapter->query('ALTER TABLE album modify id_origine varchar(255)'); +} catch(Exception $e) {} diff --git a/library/digital_resources/Lekiosk/Service.php b/library/digital_resources/Lekiosk/Service.php index 6a0a427a31b302a29eafea2bfb3527f65e042f54..24f8fe8db23f96f2f1002c61f17085b84a153fd3 100644 --- a/library/digital_resources/Lekiosk/Service.php +++ b/library/digital_resources/Lekiosk/Service.php @@ -1,3 +1,4 @@ + <?php /** * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. @@ -120,4 +121,10 @@ class Lekiosk_Service extends Class_DigitalResource_Service { ? $result['token'] : null; } + + + protected function _deleteNonHarvested() { + return $this->_deleteNonHarvestedAlbums(); + } + } \ No newline at end of file diff --git a/library/digital_resources/Lekiosk/Service/Parser.php b/library/digital_resources/Lekiosk/Service/Parser.php index a06ffa2539148900f28650aecc58df88398a9d67..bccf4d822729d6e53e9f63f680fd3be4e2c6274f 100644 --- a/library/digital_resources/Lekiosk/Service/Parser.php +++ b/library/digital_resources/Lekiosk/Service/Parser.php @@ -37,7 +37,7 @@ class Lekiosk_Service_Parser { $album = new Lekiosk_Service_Album(); $album - ->setId($attribs['PUBLICATIONID']) + ->setId($attribs['PUBLICATIONID'].':'.$attribs['ISSUENUMBER']) ->setTitle($this->_getTitle($attribs)) ->setExternalUri($attribs['SSOURL']) ->setDescription($attribs['ISSUEDESCRIPTION']) diff --git a/library/digital_resources/Lekiosk/tests/LekioskTest.php b/library/digital_resources/Lekiosk/tests/LekioskTest.php index bda3e4be0fa4cff241980cc6321808b0b6d75182..e0ddb360028fd3ebcaeef74150042705e4e364d7 100644 --- a/library/digital_resources/Lekiosk/tests/LekioskTest.php +++ b/library/digital_resources/Lekiosk/tests/LekioskTest.php @@ -314,8 +314,8 @@ class LekioskServiceHarvestTest extends LekioskServiceTestCase { /** @test */ - public function nationalSportIdShouldBe851749() { - $this->assertEquals(851749, $this->_10_national_sport->getIdOrigine()); + public function nationalSportIdShouldBe851749419() { + $this->assertEquals('851749:419', $this->_10_national_sport->getIdOrigine()); } /** @test */ @@ -576,14 +576,59 @@ abstract class LekioskServiceHttpHarvestingTestCase extends AbstractControllerTe $service = new Lekiosk_Service($config); $service->harvest(); + Class_Album::clearCache(); + } +} + + + + +class LekioskServiceHttpUpdateHarvestingTest extends LekioskServiceHttpHarvestingTestCase { + + public function setUp() { + parent::setUp(); + + $token_json = file_get_contents(__DIR__. '/token.json'); + $http_client = $this->mock() + ->whenCalled('postRawData') + ->with('https://apipros.lekiosk.com/login', + '{"username":"FOIX","userpwd":"PWD"}','application/json') + ->answers($token_json) + + ->whenCalled('open_url') + ->with('https://apipros.lekiosk.com/publications/flow', + ['headers' => ['Authorization' => 'JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MjY2MjAxNiwibmFtZSI6Illvbm5lQGdtYWlsLmNvbSIsImV4cCI6MTUxNzM5OTE0M30.qZuwpsrZmk95LU0XYKPBFqpJJ4wxOVyZnJ_Gt3panxw']]) + ->answers(file_get_contents(__DIR__. '/updated_catalogue_from_http.xml')) + ->whenCalled('open_url') + ->answers(null); + Lekiosk_Service::setDefaultHttpClient($http_client); + $config = Lekiosk_Config::getInstance(); + $config->setTimeSource(new TimeSourceForTest('2019-02-06 10:00:00')); + $service = new Lekiosk_Service($config); + $service->harvest(); Class_Album::clearCache(); } + + + /** @test */ + public function allPreviousAlbumShouldBeDeleted() { + $this->assertCount(2, Class_Album::findAll()); + } + + + /** @test */ + public function oneAlbumTitleShouldBe10NationalSport() { + $this->assertEquals('Le 10 Sport National n°440 : 6 décembre 2018', Class_Album::find(4)->getTitre()); + } + + } + class LekioskServiceHttpHarvestingTest extends LekioskServiceHttpHarvestingTestCase { /** @test */ public function contextShouldExpectation() { diff --git a/library/digital_resources/Lekiosk/tests/updated_catalogue_from_http.xml b/library/digital_resources/Lekiosk/tests/updated_catalogue_from_http.xml new file mode 100644 index 0000000000000000000000000000000000000000..f5f17c236f16b3cd67bc511c22333336dd350175 Binary files /dev/null and b/library/digital_resources/Lekiosk/tests/updated_catalogue_from_http.xml differ diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php index 130fc2256daa48b5e47f16f759c94b82722c24dc..2a93c139cb49430425f199046b61e1623947fb53 100644 --- a/tests/db/UpgradeDBTest.php +++ b/tests/db/UpgradeDBTest.php @@ -2392,3 +2392,17 @@ class UpgradeDB_360_Test extends UpgradeDBTestCase { /** @test */ public function placeholderForSigbStandardCodificationsMigration() {} } + + + + +class UpgradeDB_361_Test extends UpgradeDBTestCase { + public function prepare() { + $this->silentQuery('ALTER TABLE album modify id_origine varchar(50)'); + } + + /** @test */ + public function idOrigineLengthShouldBe255() { + $this->assertFieldType('album','id_origine', 'varchar(255)'); + } +} \ No newline at end of file