Commit 36a2a73b by Patrick Barroca

Merge branch 'dev-thumbnail-mocking' into 'master'

Dev thumbnail mocking

See merge request !2728
parents 9974493e 1c9a3468
Pipeline #4579 passed with stage
in 35 minutes 51 seconds
......@@ -171,6 +171,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe
Class_Url::setBaseUrl(BASE_URL);
Class_Url::setPhpMode('apache');
Class_AdminVar::set('NOM_DOMAINE', 'http://localhost');
Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock()->whenCalled('execTimedScript')->answers(''));
}
......
......@@ -16,41 +16,41 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once 'AdminAbstractControllerTestCase.php';
abstract class HarvestControllerToutApprendreTestCase extends Admin_AbstractControllerTestCase {
protected $_web_client;
abstract class HarvestControllerToutApprendreTestCase
extends Admin_AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$_web_client;
public function setUp() {
parent::setUp();
$this->_web_client = Storm_Test_ObjectWrapper::mock()
->whenCalled('open_url')->answers('');
Class_WebService_BibNumerique_ToutApprendre::setDefaultHttpClient($this->_web_client);
Class_WebService_BibNumerique_Vignette::setInstance(Storm_Test_ObjectWrapper::mock()
->whenCalled('updateAlbum')
->answers(true));
$this->_web_client = $this->mock()
->whenCalled('open_url')->answers('');
Class_AlbumCategorie::beVolatile();
Class_Album::beVolatile();
Class_WebService_BibNumerique_ToutApprendre::setDefaultHttpClient($this->_web_client);
Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock()
->whenCalled('execTimedScript')
->answers(''));
$this->onLoaderOfModel('Class_AlbumRessource')
->whenCalled('getNextOrderFor')
->answers(1)
->whenCalled('delete')
->answers(true)
->whenCalled('save')
->answers(true);
}
}
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AlbumRessource')
->whenCalled('getNextOrderFor')
->answers(1)
->whenCalled('delete')
->answers(true)
->whenCalled('save')
->answers(true);
}
}
abstract class HarvestControllerToutApprendreNotActivatedTestCase extends HarvestControllerToutApprendreTestCase {
public function setUp() {
parent::setUp();
......@@ -105,7 +105,7 @@ class HarvestControllerToutApprendreActivatedWithErrorTest extends HarvestContro
->with('')
->answers('');
$this->dispatch('/admin/harvest/toutapprendre', true);
$this->dispatch('/admin/harvest/toutapprendre', true);
}
......@@ -125,7 +125,7 @@ class HarvestControllerToutApprendreActivatedWithErrorTest extends HarvestContro
class HarvestControllerToutApprendreActivatedWithCoursTest extends HarvestControllerToutApprendreWithCoursTestCase {
protected
protected
$_albumWrapper;
public function setUp() {
......@@ -135,7 +135,7 @@ class HarvestControllerToutApprendreActivatedWithCoursTest extends HarvestContro
->whenCalled('deleteBy')
->answers(null);
$this->dispatch('/admin/harvest/toutapprendre', true);
$this->dispatch('/admin/harvest/toutapprendre', true);
}
......@@ -166,7 +166,7 @@ class HarvestControllerToutApprendreActivatedWithCoursTest extends HarvestContro
class HarvestControllerToutApprendreBrowse extends HarvestControllerToutApprendreWithCoursTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/admin/harvest/toutapprendre-browse', true);
$this->dispatch('/admin/harvest/toutapprendre-browse', true);
}
......@@ -224,4 +224,3 @@ EOXML;
}
}
......@@ -32,13 +32,14 @@ abstract class HarvestControllerVodeclicTestCase extends Admin_AbstractControlle
->whenCalled('open_url')->answers('');
Class_WebService_BibNumerique_Vodeclic::setDefaultHttpClient($this->_web_client);
Class_WebService_BibNumerique_Vignette::setInstance(Storm_Test_ObjectWrapper::mock()
->whenCalled('updateAlbum')
->answers(true));
Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock()
->whenCalled('execTimedScript')
->answers(''));
}
}
abstract class HarvestControllerVodeclicNotActivatedTestCase extends HarvestControllerVodeclicTestCase {
public function setUp() {
parent::setUp();
......
......@@ -79,6 +79,8 @@ abstract class ModelTestCase extends Storm_Test_ModelTestCase {
Class_Url::setBaseUrl('/bokeh');
Class_Url::setPhpMode('apache');
Class_AdminVar::set('NOM_DOMAINE', 'http://localhost');
Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock()
->whenCalled('execTimedScript')->answers(''));
}
......
......@@ -25,14 +25,14 @@ abstract class Class_WebService_Album_VignetteTestCase extends Storm_Test_ModelT
public function setUp() {
parent::setup();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Album')
->whenCalled('save')
->answers(true);
$this->onLoaderOfModel('Class_Album')
->whenCalled('save')
->answers(true);
Class_WebService_BibNumerique_Vignette::resetInstance();
$this->_vignette = Class_WebService_BibNumerique_Vignette::getInstance();
$this->_http_client = Storm_Test_ObjectWrapper::mock();
$this->_http_client = $this->mock();
Class_WebService_BibNumerique_Vignette::setDefaultHttpClient($this->_http_client);
}
......
......@@ -32,22 +32,20 @@ class NumilogTest extends ModelTestCase {
Class_AdminVar::newInstanceWithId('NUMILOG_OAI_URL', ['valeur' => 'http://numilog-oai-url']);
Class_AdminVar::newInstanceWithId('NUMILOG_URL', ['valeur' => 'http://numilog-oai-url']);
Class_AdminVar::newInstanceWithId('NUMILOG_OAI_IDBIB', ['valeur' => '44']);
$catalogue_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/numilog_catalogue.xml');
$catalogue_end_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/numilog_end.xml');
$this->_http_client = Storm_Test_ObjectWrapper::mock();
$this->_http_client
->whenCalled('open_url')
->with('http://numilog-oai-url?verb=ListRecords&metadataPrefix=oai_dc&set=bib%3A44')
->answers($catalogue_xml)
->whenCalled('open_url')
->with('http://numilog-oai-url?verb=ListRecords&resumptionToken=769701498%21500%21oai_dc%21bib%3A44%21')
->answers($catalogue_end_xml)
->beStrict();
Class_WebService_BibNumerique_Numilog::setDefaultHttpClient($this->_http_client);
Class_WebService_BibNumerique_Vignette::setInstance(Storm_Test_ObjectWrapper::mock()
->whenCalled('updateAlbum')
->answers(true));
$this->_http_client = $this->mock()
->whenCalled('open_url')
->with('http://numilog-oai-url?verb=ListRecords&metadataPrefix=oai_dc&set=bib%3A44')
->answers($catalogue_xml)
->whenCalled('open_url')
->with('http://numilog-oai-url?verb=ListRecords&resumptionToken=769701498%21500%21oai_dc%21bib%3A44%21')
->answers($catalogue_end_xml)
->beStrict();
$codif_type_doc = $this->fixture('Class_CodifTypeDoc',
['id' => Class_TypeDoc::NUMILOG,
......@@ -60,7 +58,6 @@ class NumilogTest extends ModelTestCase {
'codif_type_doc' => $codif_type_doc,
'label'=> 'Livres Numériques']);
Class_Album::beVolatile();
$this->fixture('Class_CodifMatiere', ['id' => '132',
'libelle'=>'Management',
'code_alpha' => 'MANAGEMENT']);
......@@ -71,20 +68,30 @@ class NumilogTest extends ModelTestCase {
'libelle'=>'Psychologie',
'code_alpha' => 'PSYCHOLOGIE']);
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Album')
->whenCalled('deleteBy')
->answers(true);
$this->onLoaderOfModel('Class_Album')
->whenCalled('deleteBy')
->answers(true);
$this->_numilog = new Class_WebService_BibNumerique_Numilog();
Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock()
->whenCalled('execTimedScript')
->answers(''));
Class_WebService_BibNumerique_Numilog::setDefaultHttpClient($this->_http_client);
$this->_numilog->harvest('');
$this->_first_livre_numerique = $this->_numilog->loadPage(1)->getRessourcesNumeriques()[0];
$this->_first_album = $this->_numilog->getAlbums()[0];
$this->_second_album = $this->_numilog->getAlbums()[1];
$this->_third_album = $this->_numilog->getAlbums()[2];
}
public function tearDown() {
Class_WebService_BibNumerique_RessourceNumerique::setCommand(null);
Class_WebService_BibNumerique_Numilog::setDefaultHttpClient(null);
parent::tearDown();
}
......@@ -149,7 +156,7 @@ class NumilogTest extends ModelTestCase {
/** @test */
public function thirdAlbumShouldBeSaved() {
$this->assertEquals(1, count(Class_Album::findFirstBy(['titre' => 'Stress et burnout au travail'])));
$this->assertNotNull(Class_Album::findFirstBy(['titre' => 'Stress et burnout au travail']));
}
......
......@@ -30,17 +30,16 @@ class ToutApprendreTest extends ModelTestCase {
RessourcesNumeriquesFixtures::activateToutApprendre();
$catalogue_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/toutapprendre_catalogue.xml');
$http_client = $this->mock();
$http_client
->whenCalled('open_url')
->with('http://biblio.toutapprendre.com/cours/catalogue.aspx?pk=2100')
->answers($catalogue_xml)
->beStrict();
$http_client = $this->mock()
->whenCalled('open_url')
->with('http://biblio.toutapprendre.com/cours/catalogue.aspx?pk=2100')
->answers($catalogue_xml)
->beStrict();
Class_WebService_BibNumerique_ToutApprendre::setDefaultHttpClient($http_client);
Class_WebService_BibNumerique_Vignette::setInstance($this->mock()
->whenCalled('updateAlbum')
->answers(true));
Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock()
->whenCalled('execTimedScript')
->answers(''));
$this->fixture('Class_CosmoVar', ['id' => 'types_docs', 'liste' => '']);
......
......@@ -16,66 +16,63 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class VodeclicTest extends Storm_Test_ModelTestCase{
protected static $vodeclic;
class VodeclicTest extends ModelTestCase {
protected
$_storm_default_to_volatile = true,
$_vodeclic,
$_first_album;
public function setUp() {
parent::setUp();
public static function setUpBeforeClass() {
Class_AdminVar::newInstanceWithId('VODECLIC_ID', ['valeur' => 'api-test']);
Class_AdminVar::newInstanceWithId('VODECLIC_KEY', ['valeur' => '6m5js1dPpFNrtAJbsfXO']);
Class_AdminVar::newInstanceWithId('VODECLIC_BIB_ID', ['valeur' => '12']);
$catalogue_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/vodeclic_catalogue.xml');
$http_client = Storm_Test_ObjectWrapper::mock();
$http_client
->whenCalled('open_url')
->with('https://lms.vodeclic.com/api/catalogue.xml?partenaire=api-test&encrypted_partenaire=f13eba4953115a58bdf7952266ecca9fee8f91ddac6ac901042fdb188db02778&bib_id=12')
->answers($catalogue_xml);
Class_WebService_BibNumerique_Vodeclic::setDefaultHttpClient($http_client);
Class_WebService_BibNumerique_Vignette::setInstance(Storm_Test_ObjectWrapper::mock()
->whenCalled('updateAlbum')
->answers(true));
Class_AdminVar::newInstanceWithId('VODECLIC_BIB_ID', ['valeur' => '12']);
Class_Album::beVolatile();
$catalogue_xml = file_get_contents(__DIR__ . '/../../../fixtures/vodeclic_catalogue.xml');
$http_client = $this->mock()
->whenCalled('open_url')
->with('https://lms.vodeclic.com/api/catalogue.xml?partenaire=api-test&encrypted_partenaire=f13eba4953115a58bdf7952266ecca9fee8f91ddac6ac901042fdb188db02778&bib_id=12')
->answers($catalogue_xml);
Class_Album::setFileSystem(Storm_Test_ObjectWrapper::mock()
->whenCalled('rmdir')
->answers(1));
Class_AlbumRessource::beVolatile();
Class_AlbumCategorie::beVolatile();
Class_WebService_BibNumerique_Vodeclic::setDefaultHttpClient($http_client);
Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock()
->whenCalled('execTimedScript')
->answers(''));
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AlbumRessource')
->whenCalled('getNextOrderFor')
->answers(1);
Class_Album::setFileSystem($this->mock()->whenCalled('rmdir')->answers(1));
$codif_type_doc = self::fixture('Class_CodifTypeDoc', ['id' => Class_TypeDoc::VODECLIC,
'famille_id' => Class_CodifTypeDoc::INCONNU,
'bibliotheques' => '1;8',
'annexes' => '10;12',
'sections' => '18;19']);
$this->onLoaderOfModel('Class_AlbumRessource')
->whenCalled('getNextOrderFor')
->answers(1);
self::fixture('Class_TypeDoc', ['id' => Class_TypeDoc::VODECLIC,
'codif_type_doc' => $codif_type_doc,
'label' => 'Formation Vodéclic']);
$this->fixture('Class_CosmoVar',
['id' => 'types_docs',
'liste' => '']);
self::$vodeclic = new Class_WebService_BibNumerique_Vodeclic();
self::$vodeclic->harvest('');
}
$codif_type_doc = $this->fixture('Class_CodifTypeDoc',
['id' => Class_TypeDoc::VODECLIC,
'famille_id' => Class_CodifTypeDoc::INCONNU,
'bibliotheques' => '1;8',
'annexes' => '10;12',
'sections' => '18;19']);
public function setUp() {
parent::setUp();
$this->_vodeclic = self::$vodeclic;
$this->fixture('Class_TypeDoc', ['id' => Class_TypeDoc::VODECLIC,
'codif_type_doc' => $codif_type_doc,
'label' => 'Formation Vodéclic']);
$this->_vodeclic = new Class_WebService_BibNumerique_Vodeclic();
$this->_vodeclic->harvest('');
$this->_first_album = $this->_vodeclic->getAlbums()[0];
}
/**
/**
* [[file:~/www/afi-opac/tests/fixtures/vodeclic_catalogue.xml::<titre>Safari%202</titre][formation Safari2]]
* @test
* @test
*/
public function firstAlbumTitreShouldBeSafari2() {
$this->assertEquals('Safari 2', $this->_first_album->getTitre());
......@@ -94,40 +91,40 @@ class VodeclicTest extends Storm_Test_ModelTestCase{
}
/** @test */
/** @test */
public function firstAlbumSafari2LinkShouldBeSet() {
$this->assertEquals('https://lms.vodeclic.com/api/catalogue.xml?',$this->_first_album->getUrlOrigine());
}
/** @test */
public function firstAlbumExternalURIShouldBeSet() {
$this->assertEquals('http://biblio.vodeclic.com/formation/1',$this->_first_album->getExternalUri());
}
/** @test */
public function firstAlbumSafari2DesciptionShouldBeSet() {
$this->assertEquals("Le parcours pédagogiques Safari 2 de A à Z va vous permettre de prendre complètement en main ce navigateur internet installé par défaut sur tous les ordinateurs Apple. Vous y découvrirez une navigation sur Internet simplifiée à l'aide de la barre d'adresse, du champs de recherche Google, des onglets de Safari 2… Nos vidéos-formations vous apprendront également des astuces pour mieux vivre internet au quotidien avec Safari 2. Ainsi vous apprendrez à maîtriser l'historique, vos signets, les formulaires de remplissage automatique et plein d'autres choses !",$this->_first_album->getDescription());
$this->assertEquals("Le parcours pédagogiques Safari 2 de A à Z va vous permettre de prendre complètement en main ce navigateur internet installé par défaut sur tous les ordinateurs Apple. Vous y découvrirez une navigation sur Internet simplifiée à l'aide de la barre d'adresse, du champs de recherche Google, des onglets de Safari 2… Nos vidéos-formations vous apprendront également des astuces pour mieux vivre internet au quotidien avec Safari 2. Ainsi vous apprendrez à maîtriser l'historique, vos signets, les formulaires de remplissage automatique et plein d'autres choses !",
$this->_first_album->getDescription());
}
/** @test */
public function firstAlbumSafari2IdLangueShouldBeFre() {
$this->assertEquals('fre',$this->_first_album->getIdLangue());
}
/** @test */
public function firstAlbumSafari2AnneeShouldBe2007 (){
$this->assertEquals('2007',$this->_first_album->getAnnee());
}
}
/** @test */
public function firstAlbumSafari2TypeDocShouldBeFormationVodeclic() {
$this->assertEquals('Formation Vodéclic',$this->_first_album->getTypeDoc()->getLabel());
$this->assertEquals('Formation Vodéclic', $this->_first_album->getTypeDoc()->getLabel());
}
......@@ -144,9 +141,10 @@ class VodeclicTest extends Storm_Test_ModelTestCase{
}
/** @disabledtest */
/** @test */
public function vignetteShouldHaveBeenUploaded() {
$this->assertTrue(Class_WebService_BibNumerique_Vignette::getInstance()->methodHasBeenCalled('updateAlbum'));
$this->assertTrue(Class_WebService_BibNumerique_RessourceNumerique::getCommand()
->methodHasBeenCalled('execTimedScript'));
}
......@@ -166,11 +164,4 @@ class VodeclicTest extends Storm_Test_ModelTestCase{
public function sectionsShouldBeImportedInThirdAlbum() {
$this->assertEquals('18;19',$this->_vodeclic->getAlbums()[2]->getSections());
}
}
?>
\ No newline at end of file
......@@ -19,9 +19,6 @@
<testsuite name="DigitalResourcesTestSuite">
<directory>../library/digital_resources/</directory>
</testsuite>
<testsuite name="StormTestSuite">
<directory>../library/storm/tests/Storm/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
......
Markdown is supported
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