From 149bfa4740a3649a6e1ff83ece1be75d6e8dae3e Mon Sep 17 00:00:00 2001
From: Laurent Laffont <llaffont@afi-sa.fr>
Date: Wed, 31 Oct 2018 15:53:23 +0100
Subject: [PATCH] hotline #81053 Skilleos : fetch thumbnail from 'picture'
 field

---
 library/digital_resources/Skilleos/Service/Parser.php     | 2 +-
 library/digital_resources/Skilleos/tests/SkilleosTest.php | 7 +++++++
 library/digital_resources/Skilleos/tests/results.json     | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/library/digital_resources/Skilleos/Service/Parser.php b/library/digital_resources/Skilleos/Service/Parser.php
index d787b58dd13..d6c94243d53 100644
--- a/library/digital_resources/Skilleos/Service/Parser.php
+++ b/library/digital_resources/Skilleos/Service/Parser.php
@@ -28,7 +28,7 @@ class Skilleos_Service_Parser extends Class_WebService_BibNumerique_RessourceNum
          ->setDescription($json->introduction.$json->description.$json->contenu_and_objectif);
 
     $this->_lessons = [];
-    $this->_posters[] = $json->ressource->url;
+    $this->_posters[] = isset($json->picture) ? $json->picture->url : $json->ressource->url;
 
     $this->addAuthor($json->teacher->name);
 
diff --git a/library/digital_resources/Skilleos/tests/SkilleosTest.php b/library/digital_resources/Skilleos/tests/SkilleosTest.php
index 5208cff5b32..3c78a91fe07 100644
--- a/library/digital_resources/Skilleos/tests/SkilleosTest.php
+++ b/library/digital_resources/Skilleos/tests/SkilleosTest.php
@@ -281,6 +281,13 @@ class SkilleosServiceHarvestTest extends SkilleosServiceTestCase {
     $this->assertEquals('Tatiana Abbey', Class_Album::find(6)->getAuthors()[0]->getName());
   }
 
+
+  /** @test */
+  public function thumbnailShouldBeThumbDotpng() {
+    $this->assertEquals('https://moncompte.skilleos.com/uploads/ressources/default/0001/11/thumb_10683_default_big.png', Class_Album::find(6)->getPoster());
+  }
+
+
   /** @test */
   public function withoutUserConnectionLinkToModuleSkilleosShouldIndicateToConnect() {
     ZendAfi_Auth::getInstance()->clearIdentity();
diff --git a/library/digital_resources/Skilleos/tests/results.json b/library/digital_resources/Skilleos/tests/results.json
index b0a6f42ce82..a4defa386ec 100644
--- a/library/digital_resources/Skilleos/tests/results.json
+++ b/library/digital_resources/Skilleos/tests/results.json
@@ -105,7 +105,7 @@
       "url": "https:\/\/moncompte.skilleos.com\/uploads\/ressources\/default\/0001\/12\/thumb_11660_default_big.png"
     },
     "id": 677,
-    "ressource": {
+    "picture": {
       "url": "https:\/\/moncompte.skilleos.com\/uploads\/ressources\/default\/0001\/12\/thumb_11659_default_big.png"
     }
   },
-- 
GitLab