]> git.agnieray.net Git - galette.git/blob - tests/Galette/Entity/tests/units/Texts.php
Remove 'svn' lines
[galette.git] / tests / Galette / Entity / tests / units / Texts.php
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * Text tests
7 *
8 * PHP version 5
9 *
10 * Copyright © 2019-2023 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 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
34 * @since 2019-12-20
35 */
36
37 namespace Galette\Entity\test\units;
38
39 use PHPUnit\Framework\TestCase;
40 use Galette\GaletteTestCase;
41 use Laminas\Db\Adapter\Adapter;
42
43 /**
44 * Text tests
45 *
46 * @category Entity
47 * @name Texts
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
53 * @since 2019-12-20
54 */
55 class Texts extends GaletteTestCase
56 {
57 private array $remove = [];
58
59 /**
60 * Test getList
61 *
62 * @return void
63 */
64 public function testGetList()
65 {
66 $count_texts = 13;
67 $texts = new \Galette\Entity\Texts(
68 $this->preferences
69 );
70 $texts->installInit();
71
72 $list = $texts->getRefs(\Galette\Core\I18n::DEFAULT_LANG);
73 $this->assertCount($count_texts, $list);
74
75 foreach (array_keys($this->i18n->getArrayList()) as $lang) {
76 $list = $texts->getRefs($lang);
77 $this->assertCount($count_texts, $list);
78 }
79
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);
86
87 $this->zdb->db->query(
88 'SELECT setval(\'' . PREFIX_DB . $texts::TABLE . '_id_seq\', 1)',
89 Adapter::QUERY_MODE_EXECUTE
90 );
91 }
92
93 //reinstall texts
94 $texts->installInit(false);
95
96 $list = $texts->getRefs(\Galette\Core\I18n::DEFAULT_LANG);
97 $this->assertCount($count_texts, $list);
98
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);
105 }
106 }
107 }