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

rel #13283 : NoticeTest refacto

parent b8df02c7
Branches
Tags
3 merge requests!258Dev/13872 Orphee Allow Hold Available Items,!108Dev#13283 Export Pret Unimarc,!99Dev#13283 Export Pret Unimarc
......@@ -22,12 +22,10 @@ require_once 'Class/Notice.php';
require_once 'ModelTestCase.php';
class NoticeFixtures extends TestFixtures {
protected $_fixtures = array(
'millenium' => array('id_notice' => 12,
'titres' => 'MILLENIUM'),
'potter' => array('id_notice' => 48,
'titres' => 'POTTER')
);
protected $_fixtures = ['millenium' => ['id_notice' => 12,
'titres' => 'MILLENIUM'],
'potter' => ['id_notice' => 48,
'titres' => 'POTTER']];
public static function instance() {
return new self();
......@@ -39,6 +37,7 @@ class NoticeFixtures extends TestFixtures {
class NoticeTestFindAll extends ModelTestCase {
public function setUp() {
parent::setUp();
$this->_setFindAllExpectation('Class_Notice', 'NoticeFixtures');
$this->notices = Class_Notice::getLoader()->findAll();
}
......@@ -63,6 +62,7 @@ class NoticeTestFindAll extends ModelTestCase {
class NoticeTestTypeDoc extends ModelTestCase {
public function setUp() {
parent::setUp();
$this->livre = new Class_Notice();
$this->livre->setTypeDoc(1);
......@@ -70,12 +70,16 @@ class NoticeTestTypeDoc extends ModelTestCase {
$this->periodique->setTypeDoc(2);
}
public function testIsLivre() {
/** @test */
public function isLivreShouldBeCorrect() {
$this->assertTrue($this->livre->isLivre());
$this->assertFalse($this->periodique->isLivre());
}
public function testIsPeriodique() {
/** @test */
public function isPeriodiqueShouldBeCorrect() {
$this->assertFalse($this->livre->isPeriodique());
$this->assertTrue($this->periodique->isPeriodique());
}
......@@ -86,68 +90,93 @@ class NoticeTestTypeDoc extends ModelTestCase {
class NoticeTestGetAvis extends ModelTestCase {
public function setUp() {
$this->avis_bib1 = new Class_AvisNotice();
$this->avis_bib1->setAbonOuBib(1)->setNote(4);
$this->avis_bib2 = new Class_AvisNotice();
$this->avis_bib2->setAbonOuBib(1)->setNote(5);
$this->avis_abon1 = new Class_AvisNotice();
$this->avis_abon1->setAbonOuBib(0)->setNote(2);
$this->avis_abon2 = new Class_AvisNotice();
$this->avis_abon2->setAbonOuBib(0)->setNote(3);
$this->notice = new Class_Notice();
$this->notice->setAvis(array($this->avis_bib1,
$this->avis_bib2,
$this->avis_abon1,
$this->avis_abon2));
parent::setUp();
$base_properties = ['avis' => 'Testing comment',
'entete' => 'Testing comment'];
$user_bib = $this->fixture('Class_Users',
['id' => 1,
'login' => 'admin',
'password' => 'pass',
'role_level' => ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL]);
$this->avis_bib1 = $this->fixture('Class_AvisNotice',
array_merge($base_properties,
['id' => 1,
'user' => $user_bib,
'note' => 4]));
$this->avis_bib2 = $this->fixture('Class_AvisNotice',
array_merge($base_properties,
['id' => 2,
'user' => $user_bib,
'note' => 5]));
$this->avis_abon1 = $this->fixture('Class_AvisNotice',
array_merge($base_properties,
['id' => 3,
'abon_ou_bib' => 0,
'note' => 2]));
$this->avis_abon2 = $this->fixture('Class_AvisNotice',
array_merge($base_properties,
['id' => 4,
'abon_ou_bib' => 0,
'note' => 3]));
$this->onLoaderOfModel('Class_AvisNotice')
->whenCalled('findAllBy')
->with(['clef_oeuvre' => 'TESTING-RECORD--'])
->answers([$this->avis_bib1, $this->avis_bib2,
$this->avis_abon1, $this->avis_abon2])
->beStrict();
$this->notice = $this->fixture('Class_Notice',
['id' => 12,
'clef_oeuvre' => 'TESTING-RECORD--']);
}
public function testGetAvis() {
$this->assertEquals(array($this->avis_bib1,
$this->avis_bib2,
$this->avis_abon1,
$this->avis_abon2),
/** @test */
public function getAvisShouldReturnAvisList() {
$this->assertEquals([$this->avis_bib1, $this->avis_bib2,
$this->avis_abon1, $this->avis_abon2],
$this->notice->getAvis());
}
public function testGetAvisBibliothecaires() {
$this->assertEquals(array($this->avis_bib1,
$this->avis_bib2),
/** @test */
public function getAvisBibliothecairesShouldReturnExpected() {
$this->assertEquals([$this->avis_bib1, $this->avis_bib2],
$this->notice->getAvisBibliothecaires());
}
public function testGetNoteMoyenneAvisBibliothecaires() {
/** @test */
public function noteMoyenneAvisBibliothecairesShouldBe4Dot5() {
$this->assertEquals(4.5,
$this->notice->getNoteMoyenneAvisBibliothecaires());
}
public function testGetAvisAbonnes() {
$this->assertEquals(array($this->avis_abon1,
$this->avis_abon2),
/** @test */
public function getAvisAbonnesShouldBeAsExpected() {
$this->assertEquals([$this->avis_abon1, $this->avis_abon2],
$this->notice->getAvisAbonnes());
}
public function testGetNoteMoyenneAvisAbonnes() {
/** @test */
public function noteMoyenneAvisAbonnesShouldBe2Dot5() {
$this->assertEquals(2.5,
$this->notice->getNoteMoyenneAvisAbonnes());
}
}
}
class NoticeTestNouveaute extends ModelTestCase {
public function setUp() {
parent::setUp();
$time_source = new TimeSourceForTest('2013-12-27 09:00:00');
Class_Notice::setTimeSource($time_source);
......@@ -174,12 +203,10 @@ class NoticeTestNouveaute extends ModelTestCase {
class NoticeTestTranslator extends ModelTestCase {
/** @test **/
public function noticeShouldUseTraitTranslator() {
$notice = Class_Notice::newInstanceWithId(2,['date_creation' => '1998-5-5']);
$this->assertEquals('Non',$notice->getChampNotice('9'));
}
}
......@@ -201,6 +228,7 @@ class NoticeStromaeTest extends Storm_Test_ModelTestCase {
$this->_tracks = $stromae->getMorceaux()['morceaux'];
}
/** @test */
public function tracksShouldContainsTaFete() {
$this->assertEquals('Ta fête', $this->_tracks[1][1]['titre']);
......@@ -212,18 +240,16 @@ class NoticeStromaeTest extends Storm_Test_ModelTestCase {
$this->assertEquals('Papaoutai', $this->_tracks[1][2]['titre']);
}
/** @test */
public function exportedUnimarcShouldHave995Zone() {
$unimarc=Class_Exemplaire::find(234)->toUnimarcIso2709();
$temp_file = tempnam("/tmp", "UNIMARC");
file_put_contents($temp_file,$unimarc);
$output=exec('yaz-marcdump '.$temp_file);
$this->assertContains("995",$output);
/** @test */
public function exportedUnimarcShouldHave995Zone() {
$unimarc = Class_Exemplaire::find(234)->toUnimarcIso2709();
$temp_file = tempnam('/tmp', 'UNIMARC');
file_put_contents($temp_file, $unimarc);
exec('yaz-marcdump ' . $temp_file, $output);
$this->assertContains('995', implode("\n", $output));
}
}
?>
\ 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