3 * Tests for PhpMyAdmin\Font class
5 * @package PhpMyAdmin-test
7 declare(strict_types
=1);
9 namespace PhpMyAdmin\Tests
;
12 use PhpMyAdmin\Tests\PmaTestCase
;
15 * Tests for PhpMyAdmin\Font class
17 * @package PhpMyAdmin-test
19 class FontTest
extends PmaTestCase
31 protected function setUp(): void
33 $this->font
= new Font();
37 * Test getStringWidth with different characters.
41 public function testGetStringWidth()
46 $this->font
->getStringWidth("", "arial", 10)
52 $this->font
->getStringWidth(" ", "arial", 10)
58 $this->font
->getStringWidth("a", "arial", 10)
64 $this->font
->getStringWidth("aa", "arial", 10)
70 $this->font
->getStringWidth("i", "arial", 10)
76 $this->font
->getStringWidth("f", "arial", 10)
82 $this->font
->getStringWidth("t", "arial", 10)
88 $this->font
->getStringWidth("if", "arial", 10)
94 $this->font
->getStringWidth("it", "arial", 10)
100 $this->font
->getStringWidth("r", "arial", 10)
106 $this->font
->getStringWidth("1", "arial", 10)
112 $this->font
->getStringWidth("c", "arial", 10)
118 $this->font
->getStringWidth("F", "arial", 10)
124 $this->font
->getStringWidth("A", "arial", 10)
130 $this->font
->getStringWidth("w", "arial", 10)
136 $this->font
->getStringWidth("G", "arial", 10)
142 $this->font
->getStringWidth("m", "arial", 10)
148 $this->font
->getStringWidth("W", "arial", 10)
154 $this->font
->getStringWidth("$", "arial", 10)
159 * Test getStringWidth with different fonts.
163 public function testGetStringWidthFont()
165 // string "phpMyAdmin", with Arial 10
168 $this->font
->getStringWidth("phpMyAdmin", "arial", 10)
171 // string "phpMyAdmin", with No font
174 $this->font
->getStringWidth("phpMyAdmin", "", 10)
177 // string "phpMyAdmin", with Times 10
180 $this->font
->getStringWidth("phpMyAdmin", "times", 10)
183 // string "phpMyAdmin", with Broadway 10
186 $this->font
->getStringWidth("phpMyAdmin", "broadway", 10)
191 * Test getStringWidth with different font sizes.
195 public function testGetStringWidthSize()
197 // string "phpMyAdmin", with font size 0
200 $this->font
->getStringWidth("phpMyAdmin", "arial", 0)
203 // string "phpMyAdmin", with Arial 10
206 $this->font
->getStringWidth("phpMyAdmin", "arial", 10)
209 // string "phpMyAdmin", with Arial 11
212 $this->font
->getStringWidth("phpMyAdmin", "arial", 11)
215 // string "phpMyAdmin", with Arial 20
218 $this->font
->getStringWidth("phpMyAdmin", "arial", 20)
223 * Test getStringWidth with a custom charList.
227 public function testGetStringWidthCharLists()
229 // string "a", with invalid charlist (= array without proper structure)
232 $this->font
->getStringWidth("a", "arial", 10, ["list"])
235 // string "a", with invalid charlist (= array without proper structure :
236 // modifier is missing
239 $this->font
->getStringWidth(
247 // string "a", with invalid charlist (= array without proper structure :
251 $this->font
->getStringWidth(
255 [["modifier" => 0.61]]
259 // string "a", with invalid charlist (= array without proper structure :
260 // chars is not an array
263 $this->font
->getStringWidth(
276 // string "a", with valid charlist
279 $this->font
->getStringWidth(