diff --git a/VERSIONS_WIP/180232 b/VERSIONS_WIP/180232 new file mode 100644 index 0000000000000000000000000000000000000000..6b0b02919954ed5464682cf1e00be7e332a5cd33 --- /dev/null +++ b/VERSIONS_WIP/180232 @@ -0,0 +1 @@ + - fonctionnalité #180232 : Ressource Numérique: Cafeyn : import total au lieu d'un import incrémentiel \ No newline at end of file diff --git a/library/digital_resources/Cafeyn/Service.php b/library/digital_resources/Cafeyn/Service.php index fe8ebac11113319fd659ca56391322fa1d9f0747..d0140bfc7e6444fd24e652371766a034ddb38829 100644 --- a/library/digital_resources/Cafeyn/Service.php +++ b/library/digital_resources/Cafeyn/Service.php @@ -46,6 +46,11 @@ class Cafeyn_Service extends Class_DigitalResource_Service { } + protected function _deleteNonHarvested() { + return $this->_deleteNonHarvestedAlbums(); + } + + protected function _parseJson($json) : bool{ if(!$results = json_decode($json)) return false; diff --git a/library/digital_resources/Cafeyn/tests/CafeynTest.php b/library/digital_resources/Cafeyn/tests/CafeynTest.php index b6046fdad21c1734c4c50c19a2a5bf3feb62b80a..9b2a07ff2c25dffe5ffadc264c7a85bc03974270 100644 --- a/library/digital_resources/Cafeyn/tests/CafeynTest.php +++ b/library/digital_resources/Cafeyn/tests/CafeynTest.php @@ -276,7 +276,7 @@ class CafeynDashboardActivatedTest extends CafeynActivatedTestCase { public function setUp() { parent::setUp(); - $album = $this->fixture('Class_Album', + $album = $this->fixture(Class_Album::class, ['id' => 20, 'titre' => '10 moutons', 'type_doc_id' => 'Cafeyn' @@ -322,7 +322,7 @@ class CafeynHarvestDisableUpdateTest extends CafeynServiceTestCase { public function addFixtures() { Class_AdminVar::set('Cafeyn_BATCH_UPDATE_NOTICE', '0'); - $album = $this->fixture('Class_Album', + $album = $this->fixture(Class_Album::class, ['id' => 20, 'visible' => 1, 'status' => 3, @@ -355,12 +355,13 @@ class CafeynHarvestDisableUpdateTest extends CafeynServiceTestCase { class CafeynHarvestUpdateTest extends CafeynServiceTestCase { public function setUp() { parent::setUp(); + Class_Album::find(20)->index(); } public function addFixtures() { - $album = $this->fixture('Class_Album', + $album = $this->fixture(Class_Album::class, ['id' => 20, 'titre' => '10 moutons', 'visible' => 1, @@ -369,6 +370,16 @@ class CafeynHarvestUpdateTest extends CafeynServiceTestCase { 'url_origine' => 'https://cafeyn.co/', 'type_doc_id' => 'Cafeyn' ]); + $this->fixture(Class_Album::class, + ['id' => 25, + 'titre' => 'should be deleted', + 'visible' => 1, + 'status' => 3, + 'id_origine' => '666:7', + 'url_origine' => 'https://cafeyn.co/', + 'type_doc_id' => 'Cafeyn' + ]); + return $this; } @@ -392,4 +403,10 @@ class CafeynHarvestUpdateTest extends CafeynServiceTestCase { $this->assertEquals( '2023-04-03 00:00:00', Class_Album::find(20)->getNotice()->getDateCreation()); } + + + /** @test */ + public function albumNotInJsonShouldBeDeleted() { + $this->assertNull(Class_Album::find(25)); + } }