Skip to content
Snippets Groups Projects
Commit 1ac3d514 authored by gloas's avatar gloas
Browse files

ajout des tests + refacto class abonne cosmogramme avant rel #9357

parent a3f8e749
Branches
Tags
No related merge requests found
......@@ -2170,6 +2170,8 @@ cosmogramme/sql/patch/patch_168.sql -text
cosmogramme/sql/patch/patch_169.sql -text
cosmogramme/storm_init.php -text
cosmogramme/tests/bootstrap.php -text
cosmogramme/tests/php/classes/AbonneIntegrationTest.php -text
cosmogramme/tests/php/classes/AbonneTest.php -text
cosmogramme/tests/php/classes/IndexationTest.php -text
cosmogramme/tests/php/classes/Iso2709RecordTest.php -text
cosmogramme/tests/php/classes/ModelTestCase.php -text
......
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 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).
*
* AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once 'classe_abonne.php';
require_once 'ModelTestCase.php';
abstract class AbonneIntegrationTestCase extends ModelTestCase {
protected $abon_config;
protected $user_tom;
public function setup(){
parent::setup();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users')
->whenCalled('save')
->answers(true);
$this->abon_config = new abonne();
$this->abon_config->setIdBib(2);
$this->abon_config->setChamps(['IDABON','ID_SIGB','ORDREABON','NOM','PRENOM','PASSWORD','MAIL']);
}
}
class AbonneIntegrationWithNoUsersInDbTest extends AbonneIntegrationTestCase {
public function setup(){
parent::setup();
$champs_sigb = ['1234','12','2','Tom','paul','ici','tp@afi-sa.fr'];
$champs_sigb_ascii = implode(chr(9), $champs_sigb);
$this->abon_config->importFicheAscii($champs_sigb_ascii);
$this->user_tom = Class_Users::getFirstAttributeForLastCallOn('save');
}
/** @test **/
public function abonneSigbTomIdShouldBe1234() {
$this->assertEquals('1234', $this->user_tom->getIdabon());
}
}
class AbonneIntegrationWithRoutoInDbTest extends AbonneIntegrationTestCase {
protected $user_routo;
protected $routo_after_import;
public function setup(){
parent::setup();
$this->user_routo = Class_Users::newInstanceWithId(5,['nom'=>'Routo',
'prenom'=>'Pierre',
'login'=>'routop',
'password'=>'old']);
Class_Users::whenCalled('findFirstBy')
->with(['login'=>'55',
'id_site'=>2])
->answers($this->user_routo);
$champs_sigb_ascii = implode(chr(9), ['55',
'12',
'2',
'Routo',
'Pierre',
'la',
'rp@afi-sa.fr']);
$this->abon_config->importFicheAscii($champs_sigb_ascii);
$this->routo_after_import = Class_Users::getFirstAttributeForLastCallOn('save');
}
/** @test **/
public function withRoutoInDbImportShouldUpdateRoutoWithIdabon55() {
$this->assertEquals('55',$this->routo_after_import->getIdabon());
}
/** @test **/
public function routoInDbAndRoutoAfterImportShouldBeTheSame() {
$this->assertSame($this->user_routo, $this->routo_after_import);
}
}
\ 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