3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
10 * Copyright © 2019-2023 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-2023 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 * @link http://galette.tuxfamily.org
37 namespace Galette\Entity\test\units
;
39 use PHPUnit\Framework\TestCase
;
40 use Galette\GaletteTestCase
;
41 use Laminas\Db\Adapter\Adapter
;
48 * @package GaletteTests
49 * @author Johan Cwiklinski <johan@x-tnd.be>
50 * @copyright 2019-2023 The Galette Team
51 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
52 * @link http://galette.tuxfamily.org
55 class Texts
extends GaletteTestCase
57 private array $remove = [];
64 public function testGetList()
67 $texts = new \Galette\Entity\
Texts(
70 $texts->installInit();
72 $list = $texts->getRefs(\Galette\Core\I18n
::DEFAULT_LANG
);
73 $this->assertCount($count_texts, $list);
75 foreach (array_keys($this->i18n
->getArrayList()) as $lang) {
76 $list = $texts->getRefs($lang);
77 $this->assertCount($count_texts, $list);
80 if ($this->zdb
->isPostgres()) {
81 $select = $this->zdb
->select($texts::TABLE
. '_id_seq');
82 $select->columns(['last_value']);
83 $results = $this->zdb
->execute($select);
84 $result = $results->current();
85 $this->assertGreaterThanOrEqual($count_texts, $result->last_value
, 'Incorrect texts sequence ' . $result->last_value
);
87 $this->zdb
->db
->query(
88 'SELECT setval(\'' . PREFIX_DB
. $texts::TABLE
. '_id_seq\', 1)',
89 Adapter
::QUERY_MODE_EXECUTE
94 $texts->installInit(false);
96 $list = $texts->getRefs(\Galette\Core\I18n
::DEFAULT_LANG
);
97 $this->assertCount($count_texts, $list);
99 if ($this->zdb
->isPostgres()) {
100 $select = $this->zdb
->select($texts::TABLE
. '_id_seq');
101 $select->columns(['last_value']);
102 $results = $this->zdb
->execute($select);
103 $result = $results->current();
104 $this->assertGreaterThanOrEqual(12, $result->last_value
, 'Incorrect texts sequence ' . $result->last_value
);