Newer
Older
<?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
*/
require_once('cosmogramme/php/fonctions/variables.php');
abstract class PhaseDeleteItemsTestCase extends Class_Cosmogramme_Integration_PhaseTestCase {
protected $_phase;
public function setUp() {
parent::setUp();
$this->_phase = $this->_buildPhase('DeleteItem')->run();
}
protected function _prepareFixtures() {

Arthur Suzuki
committed
$this->fixture(Class_IntProfilDonnees::class,
['id' => 102,
'libelle' => 'Suppression exemplaires',
'rejet_periodiques' => 1,
'id_article_periodique' => 0,
'accents' => Class_IntProfilDonnees::ENCODING_UTF8,
'type_fichier' => Class_IntProfilDonnees::FT_RECORDS,
'format' => Class_IntProfilDonnees::FORMAT_SEMI_COLON_ASCII,
'attributs' => [['type_doc' => [],
'champ_cote' => ''],
[],
Class_IntProfilDonnees::FORMAT_SEMI_COLON_ASCII => ['champs' => 'code_barres']]]);

Arthur Suzuki
committed
$this->fixture(Class_IntBib::class,
['id' => 2,
'nom_court' => 'petit',
'sigb' => 1]);

Arthur Suzuki
committed
$this->fixture(Class_Cosmogramme_Integration::class,
['id' => 2,
'bib' => Class_IntBib::find(2),
'profil_donnees' => Class_IntProfilDonnees::find(102),
'type_operation' => Class_Cosmogramme_Integration::TYPE_OPERATION_ITEM_DELETE,
'traite' => 'non',
'fichier' => 'barcodes_deleted.txt',
'pointeur_reprise' => 0]);
}
protected function _getPreviousPhase() {
return (new Class_Cosmogramme_Integration_Phase(1))
->beCron();
}
}
class PhaseDeleteItemsTest extends PhaseDeleteItemsTestCase {
protected function _prepareFixtures() {
parent::_prepareFixtures();

Arthur Suzuki
committed
$this->fixture(Class_Notice::class,
['id' => 2,
'clef_alpha' => 'TINTIN',
'exemplaires' => [

Arthur Suzuki
committed
$this->fixture(Class_Exemplaire::class,
['id' => 3,
'id_int_bib' => 2,
'code_barres' => 'P123']),

Arthur Suzuki
committed
$this->fixture(Class_Exemplaire::class,
['id' => 4,
'id_int_bib' => 2,
'code_barres' => 'X897'])
]
]);
}
/** @test */
public function itemP123ShouldBeDeleted() {
Class_Exemplaire::clearCache();
$this->assertNull(Class_Exemplaire::find(3));
}
/** @test */
public function newPhaseShouldBe1Dot1() {
$this->assertTrue($this->_phase->isId(1.1));
}
}
class PhaseDeleteItemsFromANSIFileTest extends PhaseDeleteItemsTestCase {
protected function _prepareFixtures() {
parent::_prepareFixtures();
Class_IntProfilDonnees::find(102)
->setAccents(Class_IntProfilDonnees::ENCODING_WINDOWS_ANSI)
->setFormat(Class_IntProfilDonnees::FORMAT_TABBED_ASCII)
->setAttributs([['type_doc' => [],
'champ_cote' => ''],
[],
Class_IntProfilDonnees::FORMAT_TABBED_ASCII => ['champs' => 'code_barres']]);
Class_Cosmogramme_Integration::find(2)
->setFichier('barcodes_deleted_ansi.txt');

Arthur Suzuki
committed
$this->fixture(Class_Notice::class,
['id' => 2,
'clef_alpha' => 'TINTIN',
'exemplaires' => [

Arthur Suzuki
committed
$this->fixture(Class_Exemplaire::class,
['id' => 3,
'id_int_bib' => 2,
'code_barres' => '02Ç9270194']),

Arthur Suzuki
committed
$this->fixture(Class_Exemplaire::class,
['id' => 4,
'id_int_bib' => 2,
'code_barres' => 'X897'])
]
]);
}
/** @test */
public function firstItemShouldBeDeleted() {
Class_Exemplaire::clearCache();
$this->assertNull(Class_Exemplaire::find(3));
}

Arthur Suzuki
committed
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
}
class PhaseDeleteItemsRecordWithSingleItemTest extends PhaseDeleteItemsTestCase {
protected function _prepareFixtures() {
parent::_prepareFixtures();
$this->fixture(Class_Notice::class,
['id' => 2,
'clef_alpha' => 'TINTIN',
'exemplaires' => [ $this->fixture(Class_Exemplaire::class,
['id' => 3,
'id_int_bib' => 2,
'code_barres' => 'P123'])]]);
}
/** @test */
public function itemP123ShouldBeDeleted() {
Class_Exemplaire::clearCache();
$this->assertNull(Class_Exemplaire::find(3));
}
/** @test */
public function recordTwoShouldBeDeleted() {
$this->assertNull(Class_Notice::find(2));
}
}