]> git.agnieray.net Git - galette.git/blob - tests/Galette/Repository/tests/units/Reminders.php
Improve Mailing constructor
[galette.git] / tests / Galette / Repository / tests / units / Reminders.php
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * Reminders repository tests
7 *
8 * PHP version 5
9 *
10 * Copyright © 2020 The Galette Team
11 *
12 * This file is part of Galette (http://galette.tuxfamily.org).
13 *
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
26 *
27 * @category Repository
28 * @package GaletteTests
29 *
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2020 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
33 * @version SVN: $Id$
34 * @link http://galette.tuxfamily.org
35 * @since 2020-09-14
36 */
37
38 namespace Galette\Repository\test\units;
39
40 use atoum;
41
42 /**
43 * Reminders repository tests
44 *
45 * @category Repository
46 * @name Remoinders
47 * @package GaletteTests
48 * @author Johan Cwiklinski <johan@x-tnd.be>
49 * @copyright 2020 The Galette Team
50 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
51 * @link http://galette.tuxfamily.org
52 * @since 2020-09-14
53 */
54 class Reminders extends atoum
55 {
56 private $zdb;
57 private $seed = 95842355;
58 private $preferences;
59 private $session;
60 private $login;
61 private $history;
62 //private $remove = [];
63 private $i18n;
64 private $contrib;
65 private $members_fields;
66 private $adh;
67 private $ids = [];
68 private $contribs_ids = [];
69
70 /**
71 * Set up tests
72 *
73 * @return void
74 */
75 public function setUp()
76 {
77 $this->zdb = new \Galette\Core\Db();
78 $ct = new \Galette\Entity\ContributionsTypes($this->zdb);
79 if (count($ct->getCompleteList()) === 0) {
80 //status are not yet instanciated.
81 $res = $ct->installInit();
82 $this->boolean($res)->isTrue();
83 }
84 }
85 /**
86 * Set up tests
87 *
88 * @param string $testMethod Calling method
89 *
90 * @return void
91 */
92 public function beforeTestMethod($testMethod)
93 {
94 $this->zdb = new \Galette\Core\Db();
95
96 $this->i18n = new \Galette\Core\I18n(
97 \Galette\Core\I18n::DEFAULT_LANG
98 );
99
100 $this->preferences = new \Galette\Core\Preferences(
101 $this->zdb
102 );
103 $this->session = new \RKA\Session();
104 $this->login = new \Galette\Core\Login($this->zdb, $this->i18n, $this->session);
105 $this->history = new \Galette\Core\History($this->zdb, $this->login, $this->preferences);
106
107 global $zdb, $login, $hist, $i18n; // globals :(
108 $zdb = $this->zdb;
109 $login = $this->login;
110 $hist = $this->history;
111 $i18n = $this->i18n;
112
113 $status = new \Galette\Entity\Status($this->zdb);
114 if (count($status->getList()) === 0) {
115 $res = $status->installInit();
116 $this->boolean($res)->isTrue();
117 }
118
119 $this->contrib = new \Galette\Entity\Contribution($this->zdb, $this->login);
120
121 include_once GALETTE_ROOT . 'includes/fields_defs/members_fields.php';
122 $this->members_fields = $members_fields;
123 $this->adh = new \Galette\Entity\Adherent($this->zdb);
124 $this->adh->setDependencies(
125 $this->preferences,
126 $this->members_fields,
127 $this->history
128 );
129 }
130
131 /**
132 * Tear down tests
133 *
134 * @param string $testMethod Calling method
135 *
136 * @return void
137 */
138 public function afterTestMethod($testMethod)
139 {
140 $delete = $this->zdb->delete(\Galette\Entity\Contribution::TABLE);
141 $delete->where(['info_cotis' => 'FAKER' . $this->seed]);
142 $this->zdb->execute($delete);
143
144 $delete = $this->zdb->delete(\Galette\Entity\Adherent::TABLE);
145 $delete->where(['fingerprint' => 'FAKER' . $this->seed]);
146 $this->zdb->execute($delete);
147
148 $delete = $this->zdb->delete(\Galette\Entity\Reminder::TABLE);
149 $this->zdb->execute($delete);
150 }
151
152 /**
153 * Test getList
154 *
155 * @return void
156 */
157 public function testGetList()
158 {
159 //impendings
160 $ireminders = new \Galette\Repository\Reminders([\Galette\Entity\Reminder::IMPENDING]);
161 $this->array($ireminders->getList($this->zdb))->isIdenticalTo([]);
162
163 //lates
164 $lreminders = new \Galette\Repository\Reminders([\Galette\Entity\Reminder::LATE]);
165 $this->array($lreminders->getList($this->zdb))->isIdenticalTo([]);
166
167 //all
168 $reminders = new \Galette\Repository\Reminders();
169 $this->array($reminders->getList($this->zdb))->isIdenticalTo([]);
170
171 //create member
172 $this->createAdherent();
173 $id = current($this->ids);
174
175 //create contribution, just about to be impending
176 $now = new \DateTime();
177 $date_begin = clone $now;
178 $date_begin->sub(new \DateInterval('P1Y'));
179 $date_begin->add(new \DateInterval('P1M'));
180 $date_end = clone $date_begin;
181 $date_end->add(new \DateInterval('P1Y'));
182
183 $this->createContrib([
184 'id_adh' => $id,
185 'id_type_cotis' => 3,
186 'montant_cotis' => '111',
187 'type_paiement_cotis' => '6',
188 'info_cotis' => 'FAKER' . $this->seed,
189 'date_fin_cotis' => $date_end->format('Y-m-d'),
190 'date_enreg' => $now->format('Y-m-d'),
191 'date_debut_cotis' => $now->format('Y-m-d')
192 ]);
193 $cid = current($this->contribs_ids);
194
195 $adh = $this->adh;
196 $this->boolean($adh->load($id))->isTrue();
197
198 //member is up to date, no reminder to send
199 $this->boolean($this->adh->isUp2Date())->isTrue();
200 $this->array($reminders->getList($this->zdb))->isIdenticalTo([]);
201
202 //create contribution, just impending
203 $date_begin = clone $now;
204 $date_begin->sub(new \DateInterval('P1Y'));
205 $date_begin->add(new \DateInterval('P1M'));
206 $date_begin->sub(new \DateInterval('P1D'));
207 $date_end = clone $date_begin;
208 $date_end->add(new \DateInterval('P1Y'));
209
210 $this->createContrib([
211 'id_adh' => $id,
212 'id_type_cotis' => 3,
213 'montant_cotis' => '111',
214 'type_paiement_cotis' => '6',
215 'info_cotis' => 'FAKER' . $this->seed,
216 'date_fin_cotis' => $date_end->format('Y-m-d'),
217 'date_enreg' => $now->format('Y-m-d'),
218 'date_debut_cotis' => $now->format('Y-m-d')
219 ]);
220 $cid = current($this->contribs_ids);
221
222 $adh = $this->adh;
223 $this->boolean($adh->load($id))->isTrue();
224
225 //member is up to date, there is one impending reminder to send
226 $this->boolean($this->adh->isUp2Date())->isTrue();
227 $this->array($reminders->getList($this->zdb))->hasSize(1);
228 $this->array($lreminders->getList($this->zdb))->hasSize(0);
229 $this->array($ireminders->getList($this->zdb))->hasSize(1);
230
231 //create contribution, just impending less than 7 days
232 $date_begin = clone $now;
233 $date_begin->sub(new \DateInterval('P1Y'));
234 $date_begin->add(new \DateInterval('P4D'));
235 $date_end = clone $date_begin;
236 $date_end->add(new \DateInterval('P1Y'));
237
238 $this->createContrib([
239 'id_adh' => $id,
240 'id_type_cotis' => 3,
241 'montant_cotis' => '111',
242 'type_paiement_cotis' => '6',
243 'info_cotis' => 'FAKER' . $this->seed,
244 'date_fin_cotis' => $date_end->format('Y-m-d'),
245 'date_enreg' => $now->format('Y-m-d'),
246 'date_debut_cotis' => $now->format('Y-m-d')
247 ]);
248 $cid = current($this->contribs_ids);
249
250 $adh = $this->adh;
251 $this->boolean($adh->load($id))->isTrue();
252
253 //member is up to date, there is one impending reminder to send
254 $this->boolean($this->adh->isUp2Date())->isTrue();
255 $this->array($reminders->getList($this->zdb))->hasSize(1);
256 $this->array($lreminders->getList($this->zdb))->hasSize(0);
257 $this->array($ireminders->getList($this->zdb))->hasSize(1);
258
259 //add a sent first impending reminder
260 $send = clone $now;
261 $send->sub(new \DateInterval('P1M'));
262 $data = array(
263 'reminder_type' => \Galette\Entity\Reminder::IMPENDING,
264 'reminder_dest' => $id,
265 'reminder_date' => $send->format('Y-m-d'),
266 'reminder_success' => true,
267 'reminder_nomail' => ($this->zdb->isPostgres() ? 'false' : 0)
268 );
269
270 $insert = $this->zdb->insert(\Galette\Entity\Reminder::TABLE);
271 $insert->values($data);
272
273 $add = $this->zdb->execute($insert);
274 $this->integer($add->count())->isGreaterThan(0);
275
276 //there is still one reminder to send
277 $this->boolean($this->adh->isUp2Date())->isTrue();
278 $this->array($reminders->getList($this->zdb))->hasSize(1);
279 $this->array($lreminders->getList($this->zdb))->hasSize(0);
280 $this->array($ireminders->getList($this->zdb))->hasSize(1);
281
282 //add a sent second impending reminder, yesterday
283 $send = clone $now;
284 $send->sub(new \DateInterval('P1D'));
285 $data = array(
286 'reminder_type' => \Galette\Entity\Reminder::IMPENDING,
287 'reminder_dest' => $id,
288 'reminder_date' => $send->format('Y-m-d'),
289 'reminder_success' => true,
290 'reminder_nomail' => ($this->zdb->isPostgres() ? 'false' : 0)
291 );
292
293 $insert = $this->zdb->insert(\Galette\Entity\Reminder::TABLE);
294 $insert->values($data);
295
296 $add = $this->zdb->execute($insert);
297 $this->integer($add->count())->isGreaterThan(0);
298
299 //nothing to send!
300 $this->boolean($this->adh->isUp2Date())->isTrue();
301 $this->array($reminders->getList($this->zdb))->hasSize(0);
302 $this->array($lreminders->getList($this->zdb))->hasSize(0);
303 $this->array($ireminders->getList($this->zdb))->hasSize(0);
304
305 //create contribution, expiration day
306 $now = new \DateTime();
307 $date_begin = clone $now;
308 $date_begin->sub(new \DateInterval('P1Y'));
309 $date_end = clone $date_begin;
310 $date_end->add(new \DateInterval('P1Y'));
311
312 $this->createContrib([
313 'id_adh' => $id,
314 'id_type_cotis' => 3,
315 'montant_cotis' => '111',
316 'type_paiement_cotis' => '6',
317 'info_cotis' => 'FAKER' . $this->seed,
318 'date_fin_cotis' => $date_end->format('Y-m-d'),
319 'date_enreg' => $now->format('Y-m-d'),
320 'date_debut_cotis' => $now->format('Y-m-d')
321 ]);
322 $cid = current($this->contribs_ids);
323
324 $adh = $this->adh;
325 $this->boolean($adh->load($id))->isTrue();
326
327 //member is up to date, no reminder to send
328 $this->boolean($this->adh->isUp2Date())->isTrue();
329 $this->array($reminders->getList($this->zdb))->isIdenticalTo([]);
330
331 //create contribution, just late
332 $now = new \DateTime();
333 $date_begin = clone $now;
334 $date_begin->sub(new \DateInterval('P1Y'));
335 $date_begin->sub(new \DateInterval('P1D'));
336 $date_end = clone $date_begin;
337 $date_end->add(new \DateInterval('P1Y'));
338
339 $this->createContrib([
340 'id_adh' => $id,
341 'id_type_cotis' => 3,
342 'montant_cotis' => '111',
343 'type_paiement_cotis' => '6',
344 'info_cotis' => 'FAKER' . $this->seed,
345 'date_fin_cotis' => $date_end->format('Y-m-d'),
346 'date_enreg' => $now->format('Y-m-d'),
347 'date_debut_cotis' => $now->format('Y-m-d')
348 ]);
349 $cid = current($this->contribs_ids);
350
351 $adh = $this->adh;
352 $this->boolean($adh->load($id))->isTrue();
353
354 //member is not up to date, but less than one month, no reminder to send
355 $this->boolean($this->adh->isUp2Date())->isFalse();
356 $this->array($reminders->getList($this->zdb))->hasSize(0);
357 $this->array($lreminders->getList($this->zdb))->hasSize(0);
358 $this->array($ireminders->getList($this->zdb))->hasSize(0);
359
360 //create contribution, late by 1 month minus 1 day
361 $now = new \DateTime();
362 $date_begin = clone $now;
363 $date_begin->sub(new \DateInterval('P1Y'));
364 $date_begin->sub(new \DateInterval('P1M'));
365 $date_begin->add(new \DateInterval('P1D'));
366 $date_end = clone $date_begin;
367 $date_end->add(new \DateInterval('P1Y'));
368
369 $this->createContrib([
370 'id_adh' => $id,
371 'id_type_cotis' => 3,
372 'montant_cotis' => '111',
373 'type_paiement_cotis' => '6',
374 'info_cotis' => 'FAKER' . $this->seed,
375 'date_fin_cotis' => $date_end->format('Y-m-d'),
376 'date_enreg' => $now->format('Y-m-d'),
377 'date_debut_cotis' => $now->format('Y-m-d')
378 ]);
379 $cid = current($this->contribs_ids);
380
381 $adh = $this->adh;
382 $this->boolean($adh->load($id))->isTrue();
383
384 //member is not up to date, but less than one month, no reminder to send
385 $this->boolean($this->adh->isUp2Date())->isFalse();
386 $this->array($reminders->getList($this->zdb))->hasSize(0);
387 $this->array($lreminders->getList($this->zdb))->hasSize(0);
388 $this->array($ireminders->getList($this->zdb))->hasSize(0);
389
390 //create contribution, late by 31 days
391 $now = new \DateTime();
392 $date_begin = clone $now;
393 $date_begin->sub(new \DateInterval('P1Y'));
394 $date_begin->sub(new \DateInterval('P31D'));
395 $date_end = clone $date_begin;
396 $date_end->add(new \DateInterval('P1Y'));
397
398 $this->createContrib([
399 'id_adh' => $id,
400 'id_type_cotis' => 3,
401 'montant_cotis' => '111',
402 'type_paiement_cotis' => '6',
403 'info_cotis' => 'FAKER' . $this->seed,
404 'date_fin_cotis' => $date_end->format('Y-m-d'),
405 'date_enreg' => $now->format('Y-m-d'),
406 'date_debut_cotis' => $now->format('Y-m-d')
407 ]);
408 $cid = current($this->contribs_ids);
409
410 $adh = $this->adh;
411 $this->boolean($adh->load($id))->isTrue();
412
413 //member is not up to date for one month, one late reminder to send
414 $this->boolean($this->adh->isUp2Date())->isFalse();
415 $this->array($reminders->getList($this->zdb))->hasSize(1);
416 $this->array($lreminders->getList($this->zdb))->hasSize(1);
417 $this->array($ireminders->getList($this->zdb))->hasSize(0);
418
419 //create contribution, late by 40 days
420 $now = new \DateTime();
421 $date_begin = clone $now;
422 $date_begin->sub(new \DateInterval('P1Y'));
423 $date_begin->sub(new \DateInterval('P40D'));
424 $date_end = clone $date_begin;
425 $date_end->add(new \DateInterval('P1Y'));
426
427 $this->createContrib([
428 'id_adh' => $id,
429 'id_type_cotis' => 3,
430 'montant_cotis' => '111',
431 'type_paiement_cotis' => '6',
432 'info_cotis' => 'FAKER' . $this->seed,
433 'date_fin_cotis' => $date_end->format('Y-m-d'),
434 'date_enreg' => $now->format('Y-m-d'),
435 'date_debut_cotis' => $now->format('Y-m-d')
436 ]);
437 $cid = current($this->contribs_ids);
438
439 $adh = $this->adh;
440 $this->boolean($adh->load($id))->isTrue();
441
442 //member is not up to date for one month, one late reminder to send
443 $this->boolean($this->adh->isUp2Date())->isFalse();
444 $this->array($reminders->getList($this->zdb))->hasSize(1);
445 $this->array($lreminders->getList($this->zdb))->hasSize(1);
446 $this->array($ireminders->getList($this->zdb))->hasSize(0);
447
448 //add a sent late reminder, at it should have been
449 $send = clone $now;
450 $send->sub(new \DateInterval('P5D'));
451 $data = array(
452 'reminder_type' => \Galette\Entity\Reminder::LATE,
453 'reminder_dest' => $id,
454 'reminder_date' => $send->format('Y-m-d'),
455 'reminder_success' => true,
456 'reminder_nomail' => ($this->zdb->isPostgres() ? 'false' : 0)
457 );
458
459 $insert = $this->zdb->insert(\Galette\Entity\Reminder::TABLE);
460 $insert->values($data);
461
462 $add = $this->zdb->execute($insert);
463 $this->integer($add->count())->isGreaterThan(0);
464
465 //nothing to send!
466 $this->boolean($this->adh->isUp2Date())->isFalse();
467 $this->array($reminders->getList($this->zdb))->hasSize(0);
468 $this->array($lreminders->getList($this->zdb))->hasSize(0);
469 $this->array($ireminders->getList($this->zdb))->hasSize(0);
470
471 //create contribution, late by 2 months
472 $now = new \DateTime();
473 $date_begin = clone $now;
474 $date_begin->sub(new \DateInterval('P1Y'));
475 $date_begin->sub(new \DateInterval('P2M'));
476 $date_end = clone $date_begin;
477 $date_end->add(new \DateInterval('P1Y'));
478
479 $this->createContrib([
480 'id_adh' => $id,
481 'id_type_cotis' => 3,
482 'montant_cotis' => '111',
483 'type_paiement_cotis' => '6',
484 'info_cotis' => 'FAKER' . $this->seed,
485 'date_fin_cotis' => $date_end->format('Y-m-d'),
486 'date_enreg' => $now->format('Y-m-d'),
487 'date_debut_cotis' => $now->format('Y-m-d')
488 ]);
489 $cid = current($this->contribs_ids);
490
491 $adh = $this->adh;
492 $this->boolean($adh->load($id))->isTrue();
493
494 //member is not up to date for one month, one late reminder to send
495 $this->boolean($this->adh->isUp2Date())->isFalse();
496 $this->array($reminders->getList($this->zdb))->hasSize(1);
497 $this->array($lreminders->getList($this->zdb))->hasSize(1);
498 $this->array($ireminders->getList($this->zdb))->hasSize(0);
499 }
500
501 /**
502 * Create test user in database
503 *
504 * @return void
505 */
506 private function createAdherent()
507 {
508 $fakedata = new \Galette\Util\FakeData($this->zdb, $this->i18n);
509 $fakedata
510 ->setSeed($this->seed)
511 ->setDependencies(
512 $this->preferences,
513 $this->members_fields,
514 $this->history,
515 $this->login
516 );
517
518 $data = $fakedata->fakeMember();
519 $this->createMember($data);
520 $this->checkMemberExpected();
521 }
522
523 /**
524 * Create member from data
525 *
526 * @param array $data Data to use to create member
527 *
528 * @return \Galette\Entity\Adherent
529 */
530 public function createMember(array $data)
531 {
532 $adh = $this->adh;
533 $check = $adh->check($data, [], []);
534 if (is_array($check)) {
535 var_dump($check);
536 }
537 $this->boolean($check)->isTrue();
538
539 $store = $adh->store();
540 $this->boolean($store)->isTrue();
541
542 $this->ids[] = $adh->id;
543 }
544
545 /**
546 * Check members expecteds
547 *
548 * @param Adherent $adh Member instance, if any
549 * @param array $new_expecteds Changes on expected values
550 *
551 * @return void
552 */
553 private function checkMemberExpected($adh = null, $new_expecteds = [])
554 {
555 if ($adh === null) {
556 $adh = $this->adh;
557 }
558
559 $expecteds = [
560 'nom_adh' => 'Hoarau',
561 'prenom_adh' => 'Lucas',
562 'ville_adh' => 'Reynaudnec',
563 'cp_adh' => '63077',
564 'adresse_adh' => '2, boulevard Legros',
565 'email_adh' => 'phoarau@tele2.fr',
566 'login_adh' => 'nathalie51',
567 'mdp_adh' => 'T.u!IbKOi|06',
568 'bool_admin_adh' => false,
569 'bool_exempt_adh' => false,
570 'bool_display_info' => false,
571 'sexe_adh' => 1,
572 'prof_adh' => 'Extraction',
573 'titre_adh' => null,
574 'ddn_adh' => '1992-02-22',
575 'lieu_naissance' => 'Fischer',
576 'pseudo_adh' => 'vallet.camille',
577 'pays_adh' => '',
578 'tel_adh' => '05 59 53 59 43',
579 'url_adh' => 'http://bodin.net/omnis-ratione-sint-dolorem-architecto',
580 'activite_adh' => true,
581 'id_statut' => 9,
582 'pref_lang' => 'ca',
583 'fingerprint' => 'FAKER' . $this->seed,
584 'societe_adh' => 'Philippe'
585 ];
586 $expecteds = array_merge($expecteds, $new_expecteds);
587
588 foreach ($expecteds as $key => $value) {
589 $property = $this->members_fields[$key]['propname'];
590 switch ($key) {
591 case 'bool_admin_adh':
592 $this->boolean($adh->isAdmin())->isIdenticalTo($value);
593 break;
594 case 'bool_exempt_adh':
595 $this->boolean($adh->isDueFree())->isIdenticalTo($value);
596 break;
597 case 'bool_display_info':
598 $this->boolean($adh->appearsInMembersList())->isIdenticalTo($value);
599 break;
600 case 'activite_adh':
601 $this->boolean($adh->isActive())->isIdenticalTo($value);
602 break;
603 case 'mdp_adh':
604 $pw_checked = password_verify($value, $adh->password);
605 $this->boolean($pw_checked)->isTrue();
606 break;
607 case 'ddn_adh':
608 //rely on age, not on birthdate
609 $this->variable($adh->$property)->isNotNull();
610 $this->string($adh->getAge())->isIdenticalTo(' (28 years old)');
611 break;
612 default:
613 $this->variable($adh->$property)->isIdenticalTo(
614 $value,
615 "$property expected {$value} got {$adh->$property}"
616 );
617 break;
618 }
619 }
620
621 $d = \DateTime::createFromFormat('Y-m-d', $expecteds['ddn_adh']);
622
623 $expected_str = ' (28 years old)';
624 $this->string($adh->getAge())->isIdenticalTo($expected_str);
625 $this->boolean($adh->hasChildren())->isFalse();
626 $this->boolean($adh->hasParent())->isFalse();
627 $this->boolean($adh->hasPicture())->isFalse();
628
629 $this->string($adh->sadmin)->isIdenticalTo('No');
630 $this->string($adh->sdue_free)->isIdenticalTo('No');
631 $this->string($adh->sappears_in_list)->isIdenticalTo('No');
632 $this->string($adh->sstaff)->isIdenticalTo('No');
633 $this->string($adh->sactive)->isIdenticalTo('Active');
634 $this->variable($adh->stitle)->isNull();
635 $this->string($adh->sstatus)->isIdenticalTo('Non-member');
636 $this->string($adh->sfullname)->isIdenticalTo('HOARAU Lucas');
637 $this->string($adh->saddress)->isIdenticalTo('2, boulevard Legros');
638 $this->string($adh->sname)->isIdenticalTo('HOARAU Lucas');
639
640 $this->string($adh->getAddress())->isIdenticalTo($expecteds['adresse_adh']);
641 $this->string($adh->getAddressContinuation())->isEmpty();
642 $this->string($adh->getZipcode())->isIdenticalTo($expecteds['cp_adh']);
643 $this->string($adh->getTown())->isIdenticalTo($expecteds['ville_adh']);
644 $this->string($adh->getCountry())->isIdenticalTo($expecteds['pays_adh']);
645
646 $this->string($adh::getSName($this->zdb, $adh->id))->isIdenticalTo('HOARAU Lucas');
647 $this->string($adh->getRowClass())->isIdenticalTo('active cotis-never');
648 }
649
650 /**
651 * Create contribution from data
652 *
653 * @param array $data Data to use to create contribution
654 *
655 * @return \Galette\Entity\Contribution
656 */
657 public function createContrib(array $data)
658 {
659 $contrib = $this->contrib;
660 $check = $contrib->check($data, [], []);
661 if (is_array($check)) {
662 var_dump($check);
663 }
664 $this->boolean($check)->isTrue();
665
666 $store = $contrib->store();
667 $this->boolean($store)->isTrue($store);
668
669 $this->contribs_ids[] = (int)$contrib->id;
670 }
671 }