Skip to content
Snippets Groups Projects
Commit 89031664 authored by efalcy's avatar efalcy
Browse files

dev #21332 : add test

parent f2e6b217
Branches
Tags 6.20
4 merge requests!780Master,!736Dev#21332 onedtouch harvest,!728Dev#21332 onedtouch harvest,!725Dev#21332 onedtouch harvest
<?php
/**
* Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* 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
*/
class OneDTouchTest extends Storm_Test_ModelTestCase {
public function setUp() {
parent::setUp();
Class_AdminVar::newInstanceWithId('ONEDTOUCH_URL', ['valeur' => 'http://dev.1dtouch.com/oai']);
$catalogue_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/onedtouch_oai.xml');
$catalogue_xml_end = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/onedtouch_oai_end.xml');
Class_Notice::beVolatile();
Class_Exemplaire::beVolatile();
Class_Album::beVolatile();
$this->_http_client = $this->mock();
$this->_http_client
->whenCalled('open_url')
->with('http://dev.1dtouch.com/oai?verb=ListRecords&metadataPrefix=oai1dtouch_dc')
->answers($catalogue_xml)
->whenCalled('open_url')
->with('http://dev.1dtouch.com/oai?verb=ListRecords&resumptionToken=oai1dtouch_dc.f%282015-02-09T08%3A46%3A09Z%29.u%282015-02-09T08%3A47%3A27Z%29%3A133')
->answers($catalogue_xml_end)
->beStrict();
$this->onLoaderOfModel('Class_Album')->whenCalled('deleteBy')->answers(true);
$this->_service = new Class_WebService_BibNumerique_OneDTouch();
Class_WebService_BibNumerique_OneDTouch::setDefaultHttpClient($this->_http_client);
$this->_service->harvest('');
}
/** @test */
public function nameShouldBeOneDTouch() {
$this->assertEquals('1DTouch', $this->_service->getName());
}
/** @test */
public function shouldBeEnabled() {
$this->assertTrue($this->_service->isEnabled());
}
/** @test */
public function shouldHaveSaved4Albums() {
$this->assertEquals(4, count(Class_Album::findAll()));
}
}
?>
\ No newline at end of file
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