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
;
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 Choice
extends atoum
56 private \Galette\Core\Db
$zdb;
57 private \Galette\DynamicFields\Choice
$choice;
62 * @param string $method Current test method
66 public function beforeTestMethod($method)
68 $this->zdb
= new \Galette\Core\
Db();
69 $this->choice
= new \Galette\DynamicFields\
Choice($this->zdb
);
77 public function testConstructor()
79 $o = new \Galette\DynamicFields\
Choice($this->zdb
, 10);
80 $this->variable($o->getId())
89 public function testGetTypeName()
91 $this->variable($this->choice
->getTypeName())
92 ->isIdenticalTo(_T('choice'));
96 * Test if basic properties are ok
100 public function testBaseProperties()
102 $muliple = $this->choice
->isMultiValued();
103 $this->boolean($muliple)->isFalse();
105 $required = $this->choice
->isRequired();
106 $this->boolean($required)->isFalse();
108 $name = $this->choice
->getName();
109 $this->variable($name)->isIdenticalTo('');
111 $has_fixed_values = $this->choice
->hasFixedValues();
112 $this->boolean($has_fixed_values)->isTrue();
114 $has_data = $this->choice
->hasData();
115 $this->boolean($has_data)->isTrue();
117 $has_w = $this->choice
->hasWidth();
118 $this->boolean($has_w)->isFalse();
120 $has_h = $this->choice
->hasHeight();
121 $this->boolean($has_h)->isFalse();
123 $has_s = $this->choice
->hasSize();
124 $this->boolean($has_s)->isFalse();
126 $perms = $this->choice
->getPerm();
127 $this->variable($perms)->isNull();
129 $width = $this->choice
->getWidth();
130 $this->variable($width)->isNull();
132 $height = $this->choice
->getHeight();
133 $this->variable($height)->isNull();
135 $repeat = $this->choice
->getRepeat();
136 $this->variable($repeat)->isNull();
138 $repeat = $this->choice
->isRepeatable();
139 $this->boolean($repeat)->isFalse();
141 $size = $this->choice
->getSize();
142 $this->variable($size)->isNull();
144 $values = $this->choice
->getValues();
145 $this->boolean($values)->isFalse();
147 $this->boolean($this->choice
->hasPermissions())->isTrue();