Skip to content
Snippets Groups Projects
Commit dd6e65ea authored by Laurent's avatar Laurent
Browse files

hotline #41683 fix thumbnail import in digital library

parent 31d13a8b
Branches
Tags
2 merge requests!1659Master,!1624Hotline#41683 probleme pnb dole
- ticket #41683 : problème pnb dole
\ No newline at end of file
......@@ -48,6 +48,12 @@ class Class_FileProperty {
if (!$this->_isInRequest())
return true;
if ($this->_hasErrorCodeOnFile())
return false;
if ($this->_isFileEmpty())
return true;
$old_file = $this->_getValue();
if (!$this->_upload())
......@@ -56,14 +62,25 @@ class Class_FileProperty {
return $this->_onUpdate($old_file);
}
public function hasErrorCodeOnFile() {
return array_key_exists('error', $_FILES[$this->_name])
&& 4 !== $_FILES[$this->_name]['error'];
protected function _hasErrorCodeOnFile() {
return
array_key_exists('error', $_FILES[$this->_name])
&&
(UPLOAD_ERR_NO_FILE !== $_FILES[$this->_name]['error']);
}
protected function _isInRequest() {
return array_key_exists($this->_name, $_FILES)
&& $this->hasErrorCodeOnFile();
return array_key_exists($this->_name, $_FILES);
}
protected function _isFileEmpty() {
return
array_key_exists('error', $_FILES[$this->_name])
&&
(UPLOAD_ERR_NO_FILE == $_FILES[$this->_name]['error']);
}
......
......@@ -256,15 +256,25 @@ abstract class AlbumHarlockFileUploadHandlerTestCase extends AlbumHarlockTestCas
class AlbumHarlockReceivingFileTest extends AlbumHarlockFileUploadHandlerTestCase {
/** @test */
public function withoutFileShouldReturnTrue() {
$_FILES['fichier']['error'] = 4;
$_FILES['fichier']['size'] = 0;
$_FILES['fichier']['error'] = UPLOAD_ERR_NO_FILE;
$this->assertTrue($this->_album->receiveFile());
}
/** @test */
public function withUploadErrorShouldReturnFalse() {
public function withPartialFileShouldReturnFalse() {
$_FILES['fichier']['size'] = 1;
$_FILES['fichier']['error'] = 0;
$_FILES['fichier']['error'] = UPLOAD_ERR_PARTIAL;
$this->assertFalse($this->_album->receiveFile());
}
/** @test */
public function withUploadErrorOnHandlerShouldReturnFalse() {
$_FILES['fichier']['size'] = 1;
unset($_FILES['fichier']['error']);
$this->_handler
->expects($this->once())
->method('receive')
......@@ -284,7 +294,7 @@ class AlbumHarlockReceivingPdfTest extends AlbumHarlockFileUploadHandlerTestCase
/** @test */
public function withoutFileShouldReturnTrue() {
$_FILES['pdf']['size'] = 0;
$_FILES['pdf']['error'] = 4;
$_FILES['pdf']['error'] = UPLOAD_ERR_NO_FILE;
$this->assertTrue($this->_album->receivePdf());
}
......@@ -292,7 +302,7 @@ class AlbumHarlockReceivingPdfTest extends AlbumHarlockFileUploadHandlerTestCase
/** @test */
public function withUploadErrorShouldReturnFalse() {
$_FILES['pdf']['size'] = 1;
$_FILES['pdf']['error'] = 0;
unset($_FILES['pdf']['error']);
$this->_handler
->expects($this->once())
->method('receive')
......
......@@ -20,12 +20,15 @@
*/
abstract class DilicomPNBOfferParserTestCase extends Storm_Test_ModelTestCase {
protected $_xml;
abstract class DilicomPNBOfferParserTestCase extends ModelTestCase {
protected
$_storm_default_to_volatile = true,
$_pnb_filename = 'full_pnb_666_20150220T150017Z.xml',
$_xml;
public function setUp() {
parent::setUp();
$xmlpath = realpath(dirname(__FILE__)) . '/fixtures/full_pnb_666_20150220T150017Z.xml';
$xmlpath = realpath(dirname(__FILE__)) . '/fixtures/' . $this->_pnb_filename;
$this->_xml = file_get_contents($xmlpath);
$this->_http_client = Storm_Test_ObjectWrapper::mock()
......@@ -33,10 +36,14 @@ abstract class DilicomPNBOfferParserTestCase extends Storm_Test_ModelTestCase {
->answers('');
Class_WebService_Abstract::setDefaultHttpClient($this->_http_client);
Storm_Model_Loader::defaultToVolatile();
Class_Album_UsageConstraint::setTimeSource(new TimeSourceForTest('2014-05-02 14:14:14'));
}
public function tearDown() {
Class_WebService_Abstract::setDefaultHttpClient(null);
parent::tearDown();
}
}
......@@ -49,12 +56,6 @@ class DilicomPNBOfferParserTest extends DilicomPNBOfferParserTestCase {
$this->_books = Class_WebService_BibNumerique_Dilicom_PNBOffersFile::booksFromXML($this->_xml);
}
public function tearDown() {
Storm_Model_Loader::defaultToDb();
Class_WebService_Abstract::setDefaultHttpClient(null);
parent::tearDown();
}
/** @test */
public function numberOfBooksShouldBeThree() {
......@@ -354,4 +355,42 @@ class DilicomPNBOfferParserUpdateWithNewOrderTest extends DilicomPNBOfferParserT
$this->_items[1]->getUsageConstraints()->getAvailabilityDuration());
}
}
class DilicomDecitresPNBOffersParserTest extends DilicomPNBOfferParserTestCase {
protected $_pnb_filename = 'full_pnb_decitres.xml';
public function setUp() {
parent::setUp();
$this->_books = Class_WebService_BibNumerique_Dilicom_PNBOffersFile::booksFromXML($this->_xml);
}
/** @test */
public function numberOfBooksShouldBeFour() {
$this->assertEquals(4, count($this->_books));
}
/** @test */
public function firstAlbumShouldBeEspritRouge() {
$album = $this->_books[0]->import();
$this->assertEquals('L’Esprit rouge', $album->getTitre());
return $album;
}
/**
* @depends firstAlbumShouldBeEspritRouge
* @test
*/
public function firstAlbumThumbnailShouldBeSmallDotJpg($album) {
$this->assertEquals('https://assets.edenlivres.fr/assets/publications/171925/cover/small.jpg',
$album->getPoster());
}
}
?>
\ No newline at end of file
This diff is collapsed.
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