3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
10 * Copyright © 2021-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 DynamicFields
28 * @package GaletteTests
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
34 * @link http://galette.tuxfamily.org
38 namespace Galette\DynamicFields\test\units
;
40 use PHPUnit\Framework\TestCase
;
45 * @category DynamicFields
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
54 class Text
extends TestCase
56 private \Galette\Core\Db
$zdb;
57 private \Galette\DynamicFields\Text
$text;
64 public function setUp(): void
66 $this->zdb
= new \Galette\Core\
Db();
67 $this->text
= new \Galette\DynamicFields\
Text($this->zdb
);
75 public function testConstructor()
77 $o = new \Galette\DynamicFields\
Text($this->zdb
, 10);
78 $this->assertNull($o->getId());
86 public function testGetTypeName()
88 $this->assertSame(_T('free text'), $this->text
->getTypeName());
92 * Test if basic properties are ok
96 public function testBaseProperties()
98 $muliple = $this->text
->isMultiValued();
99 $this->assertFalse($muliple);
101 $required = $this->text
->isRequired();
102 $this->assertFalse($required);
104 $name = $this->text
->getName();
105 $this->assertSame('', $name);
107 $has_fixed_values = $this->text
->hasFixedValues();
108 $this->assertFalse($has_fixed_values);
110 $has_data = $this->text
->hasData();
111 $this->assertTrue($has_data);
113 $has_w = $this->text
->hasWidth();
114 $this->assertTrue($has_w);
116 $has_h = $this->text
->hasHeight();
117 $this->assertTrue($has_h);
119 $has_s = $this->text
->hasSize();
120 $this->assertFalse($has_s);
122 $perms = $this->text
->getPerm();
123 $this->assertNull($perms);
125 $width = $this->text
->getWidth();
126 $this->assertNull($width);
128 $height = $this->text
->getHeight();
129 $this->assertNull($height);
131 $repeat = $this->text
->getRepeat();
132 $this->assertSame(1, $repeat);
134 $repeat = $this->text
->isRepeatable();
135 $this->assertTrue($repeat);
137 $size = $this->text
->getSize();
138 $this->assertNull($size);
140 $values = $this->text
->getValues();
141 $this->assertFalse($values);
143 $this->assertTrue($this->text
->hasPermissions());