]> git.agnieray.net Git - galette.git/blob - tests/Galette/DynamicFields/tests/units/Date.php
7b39074340c94aa980d382c9b69a908f29de2cfb
[galette.git] / tests / Galette / DynamicFields / tests / units / Date.php
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * Dynamic date 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 DynamicFields
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-11
36 */
37
38 namespace Galette\DynamicFields\test\units;
39
40 use atoum;
41
42 /**
43 * Dynamic date test
44 *
45 * @category DynamicFields
46 * @name Date
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-11
53 */
54 class Date extends atoum
55 {
56 private \Galette\Core\Db $zdb;
57 private \Galette\DynamicFields\Date $date;
58
59 /**
60 * Set up tests
61 *
62 * @param string $method Current test method
63 *
64 * @return void
65 */
66 public function beforeTestMethod($method)
67 {
68 $this->zdb = new \Galette\Core\Db();
69 $this->date = new \Galette\DynamicFields\Date($this->zdb);
70 }
71
72 /**
73 * Test constructor
74 *
75 * @return void
76 */
77 public function testConstructor()
78 {
79 $o = new \Galette\DynamicFields\Date($this->zdb, 10);
80 $this->variable($o->getId())
81 ->isNull();
82 }
83
84 /**
85 * Test get type name
86 *
87 * @return void
88 */
89 public function testGetTypeName()
90 {
91 $this->variable($this->date->getTypeName())
92 ->isIdenticalTo(_T('date'));
93 }
94
95 /**
96 * Test if basic properties are ok
97 *
98 * @return void
99 */
100 public function testBaseProperties()
101 {
102 $muliple = $this->date->isMultiValued();
103 $this->boolean($muliple)->isFalse();
104
105 $required = $this->date->isRequired();
106 $this->boolean($required)->isFalse();
107
108 $name = $this->date->getName();
109 $this->variable($name)->isIdenticalTo('');
110
111 $has_fixed_values = $this->date->hasFixedValues();
112 $this->boolean($has_fixed_values)->isFalse();
113
114 $has_data = $this->date->hasData();
115 $this->boolean($has_data)->isTrue();
116
117 $has_w = $this->date->hasWidth();
118 $this->boolean($has_w)->isFalse();
119
120 $has_h = $this->date->hasHeight();
121 $this->boolean($has_h)->isFalse();
122
123 $has_s = $this->date->hasSize();
124 $this->boolean($has_s)->isFalse();
125
126 $perms = $this->date->getPerm();
127 $this->variable($perms)->isNull();
128
129 $width = $this->date->getWidth();
130 $this->variable($width)->isNull();
131
132 $height = $this->date->getHeight();
133 $this->variable($height)->isNull();
134
135 $repeat = $this->date->getRepeat();
136 $this->variable($repeat)->isNull();
137
138 $repeat = $this->date->isRepeatable();
139 $this->boolean($repeat)->isFalse();
140
141 $size = $this->date->getSize();
142 $this->variable($size)->isNull();
143
144 $values = $this->date->getValues();
145 $this->boolean($values)->isFalse();
146
147 $this->boolean($this->date->hasPermissions())->isTrue();
148 }
149 }