Skip to content
Snippets Groups Projects
Commit 38e79bf2 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

rel #30143: fix tests

parent 6576328d
Branches
Tags
2 merge requests!1148Dev#30143 create album record thumbnail from first image,!1137Dev#30143 create album record thumbnail from first image
...@@ -1642,6 +1642,7 @@ class Class_Notice extends Storm_Model_Abstract { ...@@ -1642,6 +1642,7 @@ class Class_Notice extends Storm_Model_Abstract {
return $canvas->renderNotice($this); return $canvas->renderNotice($this);
} }
public function getFamilleId() { public function getFamilleId() {
if ($type_doc = Class_TypeDoc::find($this->getTypeDoc())) if ($type_doc = Class_TypeDoc::find($this->getTypeDoc()))
return $type_doc->getFamilleId(); return $type_doc->getFamilleId();
...@@ -1649,6 +1650,12 @@ class Class_Notice extends Storm_Model_Abstract { ...@@ -1649,6 +1650,12 @@ class Class_Notice extends Storm_Model_Abstract {
} }
public function isBookFamily() {
return ($type_doc = Class_TypeDoc::find($this->getTypeDoc())) ?
$type_doc->isBook() : false;
}
public function isNouveaute() { public function isNouveaute() {
return date('Y-m-d', self::getTimeSource()->time()) <= substr($this->getDateCreation(), 0, 10); return date('Y-m-d', self::getTimeSource()->time()) <= substr($this->getDateCreation(), 0, 10);
} }
......
...@@ -24,7 +24,7 @@ class Class_Notice_Thumbnail_ProviderFactory { ...@@ -24,7 +24,7 @@ class Class_Notice_Thumbnail_ProviderFactory {
public function newWith($file_system, $notice) { public function newWith($file_system, $notice) {
$mapping = $mapping =
['Article' => function($record) { return $record->isArticleCms(); }, ['Article' => function($record) { return $record->isArticleCms(); },
'Album' => function($record) { return $record->isRessourceNumerique(); }, 'Album' => function($record) { return $this->_isAlbum($record); },
'Site' => function($record) { return $record->isSite(); }, 'Site' => function($record) { return $record->isSite(); },
'CacheServer' => function() { return true; }]; 'CacheServer' => function() { return true; }];
...@@ -34,4 +34,10 @@ class Class_Notice_Thumbnail_ProviderFactory { ...@@ -34,4 +34,10 @@ class Class_Notice_Thumbnail_ProviderFactory {
return new $class_name($file_system, $notice); return new $class_name($file_system, $notice);
} }
} }
public function _isAlbum($record) {
return $record->isRessourceNumerique()
&& !$record->isBookFamily();
}
} }
...@@ -42,8 +42,8 @@ class Class_WebService_Vignette extends Class_WebService_Abstract { ...@@ -42,8 +42,8 @@ class Class_WebService_Vignette extends Class_WebService_Abstract {
public function getThumbnailProviderFor($notice) { public function getThumbnailProviderFor($notice) {
return (new Class_Notice_Thumbnail_ProviderFactory()) $factory = new Class_Notice_Thumbnail_ProviderFactory();
->newWith($this->getFileSystem(), $notice); return $factory->newWith($this->getFileSystem(), $notice);
} }
......
...@@ -857,20 +857,20 @@ class CmsControllerArticleConcertEditActionPostTest extends CmsControllerWithPer ...@@ -857,20 +857,20 @@ class CmsControllerArticleConcertEditActionPostTest extends CmsControllerWithPer
Class_WebService_Vignette::setFileSystem($filesystem); Class_WebService_Vignette::setFileSystem($filesystem);
$image = Storm_Test_ObjectWrapper::mock(); $image = $this->mock()
Class_WebService_Thumbnail_Provider_Article::setDefaultImageFactory( ->whenCalled('thumbnailImage')
Storm_Test_ObjectWrapper::mock() ->with(160, 220, true, true)
->whenCalled('newImage') ->answers(null)
->answers($image));
->whenCalled('writeImage')
$image ->with(PATH_TEMP . 'vignettes_titre/ERIKTRUFFAZLADYLANDQUARTETENCONCERT-4-TOM----8.jpg')
->whenCalled('thumbnailImage') ->answers(null)
->with(160, 220, true, true)
->answers(null) ->beStrict();
->whenCalled('writeImage')
->with(PATH_TEMP . 'vignettes_titre/ERIKTRUFFAZLADYLANDQUARTETENCONCERT-4-TOM----8.jpg') $image_factory = $this->mock()->whenCalled('newImage')->answers($image);
->answers(null) Class_Notice_Thumbnail_ProviderAbstract::setDefaultImageFactory($image_factory);
->beStrict();
Class_Notice::beVolatile(); Class_Notice::beVolatile();
Class_NoticeDomain::beVolatile(); Class_NoticeDomain::beVolatile();
...@@ -922,7 +922,7 @@ class CmsControllerArticleConcertEditActionPostTest extends CmsControllerWithPer ...@@ -922,7 +922,7 @@ class CmsControllerArticleConcertEditActionPostTest extends CmsControllerWithPer
public function tearDown() { public function tearDown() {
Class_WebService_Vignette::setFileSystem(null); Class_WebService_Vignette::setFileSystem(null);
Class_WebService_Thumbnail_Provider_Article::setDefaultImageFactory(null); Class_Notice_Thumbnail_ProviderAbstract::setDefaultImageFactory(null);
parent::tearDown(); parent::tearDown();
} }
......
...@@ -22,19 +22,20 @@ ...@@ -22,19 +22,20 @@
class Class_WebService_VignetteTest extends Storm_Test_ModelTestCase { class Class_WebService_VignetteTest extends Storm_Test_ModelTestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$http_client = Storm_Test_ObjectWrapper::mock(); $http_client = $this->mock();
$this->fixture('Class_CodifTypeDoc', $this->fixture('Class_CodifTypeDoc',
['id' => 102, ['id' => 102,
'type_doc_id'=> 102, 'type_doc_id'=> 102,
'famille_id' => Class_CodifTypeDoc::LIVRE]); 'famille_id' => Class_CodifTypeDoc::LIVRE]);
$this->fixture('Class_Notice',['id'=> 10, $this->fixture('Class_Notice',
'titre_principal' => 'Le photographe', ['id'=> 10,
'auteur_principal' => 'Guibert', 'titre_principal' => 'Le photographe',
'isbn' => '3222222', 'auteur_principal' => 'Guibert',
'ean' => '1111111', 'isbn' => '3222222',
'type_doc' => 102]); 'ean' => '1111111',
'type_doc' => 102]);
Class_WebService_AllServices::setHttpClient($http_client); Class_WebService_AllServices::setHttpClient($http_client);
...@@ -57,7 +58,8 @@ class Class_WebService_VignetteTest extends Storm_Test_ModelTestCase { ...@@ -57,7 +58,8 @@ class Class_WebService_VignetteTest extends Storm_Test_ModelTestCase {
'statut_recherche' => 2])) 'statut_recherche' => 2]))
->beStrict(); ->beStrict();
(new Class_WebService_Vignette())->updateUrlsFromCacheServer(Class_Notice::find(10)); (new Class_WebService_Vignette())
->updateUrlsFromCacheServer(Class_Notice::find(10));
} }
...@@ -69,12 +71,14 @@ class Class_WebService_VignetteTest extends Storm_Test_ModelTestCase { ...@@ -69,12 +71,14 @@ class Class_WebService_VignetteTest extends Storm_Test_ModelTestCase {
/** @test */ /** @test */
public function vignetShouldHaveBeenUpdatedWithPotterThumbJpg() { public function vignetShouldHaveBeenUpdatedWithPotterThumbJpg() {
$this->assertEquals('http://cache.org/potter_thumb.jpg', Class_Notice::find(10)->getUrlVignette()); $this->assertEquals('http://cache.org/potter_thumb.jpg',
Class_Notice::find(10)->getUrlVignette());
} }
/** @test */ /** @test */
public function imageShouldHaveBeenUpdatedWithPotterJpg() { public function imageShouldHaveBeenUpdatedWithPotterJpg() {
$this->assertEquals('http://cache.org/potter.jpg', Class_Notice::find(10)->getUrlImage()); $this->assertEquals('http://cache.org/potter.jpg',
Class_Notice::find(10)->getUrlImage());
} }
} }
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