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