]> git.agnieray.net Git - galette.git/blob - tests/Galette/Core/tests/units/Galette.php
Migrate to phpunit; closes #1674
[galette.git] / tests / Galette / Core / tests / units / Galette.php
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * Galette tests
7 *
8 * PHP version 5
9 *
10 * Copyright © 2021-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 Core
28 * @package GaletteTests
29 *
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2021-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 * @version SVN: $Id$
34 * @link http://galette.tuxfamily.org
35 * @since 2021-11-23
36 */
37
38 namespace Galette\Core\test\units;
39
40 use Galette\GaletteTestCase;
41
42 /**
43 * Galette tests class
44 *
45 * @category Core
46 * @name Galette
47 * @package GaletteTests
48 * @author Johan Cwiklinski <johan@x-tnd.be>
49 * @copyright 2021-2023 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 2021-11-23
53 */
54 class Galette extends GaletteTestCase
55 {
56 /**
57 * Test gitVersion
58 *
59 * @return void
60 */
61 public function testGitVersion()
62 {
63 $gitversion = \Galette\Core\Galette::gitVersion();
64 $this->assertStringStartsWith(GALETTE_VERSION, $gitversion);
65 $this->assertSame(
66 1,
67 preg_match(
68 '/-git-.+ \(\d{4}-\d{2}-\d{2}\)/',
69 str_replace(GALETTE_VERSION, '', $gitversion)
70 )
71 );
72 }
73
74 /**
75 * Test storing into session of various objects to detect serialization issues
76 *
77 * @return void
78 */
79 public function testSerialization()
80 {
81 //global objects
82 $login = new \Galette\Core\Login($this->zdb, $this->i18n);
83 $this->session->login_test = $login;
84 $this->assertInstanceOf(\Galette\Core\Login::class, $this->session->login_test);
85
86 $mailing = new \Galette\Core\Mailing($this->preferences);
87 $this->session->mailing_test = $mailing;
88 $this->assertInstanceOf(\Galette\Core\Mailing::class, $this->session->mailing_test);
89
90 $gaptcha = new \Galette\Core\Gaptcha($this->i18n);
91 $this->session->gaptcha_test = $gaptcha;
92 $this->assertInstanceOf(\Galette\Core\Gaptcha::class, $this->session->gaptcha_test);
93
94 $plugin_install = new \Galette\Core\PluginInstall();
95 $this->session->plugininstall_test = $plugin_install;
96 $this->assertInstanceOf(\Galette\Core\PluginInstall::class, $this->session->plugininstall_test);
97
98 $i18n = new \Galette\Core\I18n();
99 $this->session->i18n_test = $i18n;
100 $this->assertInstanceOf(\Galette\Core\I18n::class, $this->session->i18n_test);
101
102 //entities
103 $contribution = new \Galette\Entity\Contribution($this->zdb, $this->login);
104 $this->session->contribution_test = $contribution;
105 $this->assertInstanceOf(\Galette\Entity\Contribution::class, $this->session->contribution_test);
106
107 $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, \Galette\DynamicFields\DynamicField::LINE);
108 $this->session->df_filter_test = $df;
109 $this->assertInstanceOf(\Galette\DynamicFields\Line::class, $this->session->df_filter_test);
110
111 $member = new \Galette\Entity\Adherent($this->zdb);
112 $this->session->member_test = $member;
113 $this->assertInstanceOf(\Galette\Entity\Adherent::class, $this->session->member_test);
114
115 $transaction = new \Galette\Entity\Transaction($this->zdb, $this->login);
116 $this->session->transaction_test = $transaction;
117 $this->assertInstanceOf(\Galette\Entity\Transaction::class, $this->session->transaction_test);
118
119 //filters
120 $contribution_filter = new \Galette\Filters\ContributionsList();
121 $this->session->contribution_filter_test = $contribution_filter;
122 $this->assertInstanceOf(\Galette\Filters\ContributionsList::class, $this->session->contribution_filter_test);
123
124 $member_advanced_filter = new \Galette\Filters\AdvancedMembersList();
125 $this->session->member_advanced_filter_test = $member_advanced_filter;
126 $this->assertInstanceOf(\Galette\Filters\AdvancedMembersList::class, $this->session->member_advanced_filter_test);
127
128 $member_filter = new \Galette\Filters\MembersList();
129 $this->session->member_filter_test = $member_filter;
130 $this->assertInstanceOf(\Galette\Filters\MembersList::class, $this->session->member_filter_test);
131
132 $history_filter = new \Galette\Filters\HistoryList();
133 $this->session->history_filter_test = $history_filter;
134 $this->assertInstanceOf(\Galette\Filters\HistoryList::class, $this->session->history_filter_test);
135
136 $mailing_filter = new \Galette\Filters\MailingsList();
137 $this->session->mailing_filter_test = $mailing_filter;
138 $this->assertInstanceOf(\Galette\Filters\MailingsList::class, $this->session->mailing_filter_test);
139
140 $saved_filter = new \Galette\Filters\SavedSearchesList();
141 $this->session->saved_filter_test = $saved_filter;
142 $this->assertInstanceOf(\Galette\Filters\SavedSearchesList::class, $this->session->saved_filter_test);
143
144 $transaction_filter = new \Galette\Filters\TransactionsList();
145 $this->session->transaction_filter_test = $transaction_filter;
146 $this->assertInstanceOf(\Galette\Filters\TransactionsList::class, $this->session->transaction_filter_test);
147 }
148 }