3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
6 * Payment types repository tests
10 * Copyright © 2019 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
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.
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.
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/>.
27 * @category Repository
28 * @package GaletteTests
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2019 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
34 * @link http://galette.tuxfamily.org
38 namespace Galette\Repository\test\units
;
40 use Galette\GaletteTestCase
;
43 * Payment types repository tests
45 * @category Repository
47 * @package GaletteTests
48 * @author Johan Cwiklinski <johan@x-tnd.be>
49 * @copyright 2019 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
54 class PaymentTypes
extends GaletteTestCase
61 * @param string $method Calling method
65 public function beforeTestMethod($method)
67 parent
::beforeTestMethod($method);
69 $types = new \Galette\Repository\
PaymentTypes($this->zdb
, $this->preferences
, $this->login
);
70 $res = $types->installInit(false);
71 $this->boolean($res)->isTrue();
77 * @param string $method Calling method
81 public function afterTestMethod($method)
83 parent
::afterTestMethod($method);
84 $this->deletePaymentType();
92 private function deletePaymentType()
94 if (is_array($this->remove
) && count($this->remove
) > 0) {
95 $delete = $this->zdb
->delete(\Galette\Entity\PaymentType
::TABLE
);
96 $delete->where
->in(\Galette\Repository\PaymentTypes
::PK
, $this->remove
);
97 $this->zdb
->execute($delete);
101 $this->zdb
->db
->query(
102 'TRUNCATE TABLE ' . PREFIX_DB
. \Galette\Core\History
::TABLE
,
103 \Zend\Db\Adapter\Adapter
::QUERY_MODE_EXECUTE
112 public function testGetList()
114 $types = new \Galette\Repository\
PaymentTypes($this->zdb
, $this->preferences
, $this->login
);
116 $list = $types->getList();
117 $this->array($list)->hasSize(6);
119 if ($this->zdb
->isPostgres()) {
120 $select = $this->zdb
->select(\Galette\Entity\PaymentType
::TABLE
. '_id_seq');
121 $select->columns(['last_value']);
122 $results = $this->zdb
->execute($select);
123 $result = $results->current();
124 $this->integer($result->last_value
)->isGreaterThanOrEqualTo(6, 'Incorrect payments types sequence');
127 //reinstall payment types
128 $types->installInit();
130 $list = $types->getList();
131 $this->array($list)->hasSize(6);
133 if ($this->zdb
->isPostgres()) {
134 $select = $this->zdb
->select(\Galette\Entity\PaymentType
::TABLE
. '_id_seq');
135 $select->columns(['last_value']);
136 $results = $this->zdb
->execute($select);
137 $result = $results->current();
138 $this->integer($result->last_value
)->isGreaterThanOrEqualTo(
140 'Incorrect payment types sequence ' . $result->last_value