3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
10 * Copyright © 2016-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/>.
28 * @package GaletteTests
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2016-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\Core\test\units
;
40 use PHPUnit\Framework\TestCase
;
43 * CheckModules tests class
47 * @package GaletteTests
48 * @author Johan Cwiklinski <johan@x-tnd.be>
49 * @copyright 2016-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 CheckModules
extends TestCase
61 public function tearDown(): void
63 if (TYPE_DB
=== 'mysql') {
64 $zdb = new \Galette\Core\
Db();
65 $this->assertSame([], $zdb->getWarnings());
71 * Test modules, all should be ok
75 public function testAllOK()
77 $checks = new \Galette\Core\
CheckModules();
78 $this->assertTrue($checks->isValid());
79 $this->assertGreaterThanOrEqual(6, count($checks->getGoods()));
80 $this->assertLessThanOrEqual(10, count($checks->getGoods()));
81 $this->assertSame([], $checks->getMissings());
82 $this->assertSame([], $checks->getShoulds());
83 $this->assertTrue($checks->isGood('mbstring'));
87 * Test all extensions missing
91 public function testAllKO()
93 $checks = $this->getMockBuilder(\Galette\Core\CheckModules
::class)
94 ->setConstructorArgs([false])
95 ->onlyMethods(array('isExtensionLoaded'))
97 $checks->method('isExtensionLoaded')->willReturn(false);
99 $checks->doCheck(false);
100 $this->assertSame(0, count($checks->getGoods()));
101 $this->assertSame(3, count($checks->getShoulds()));
102 $this->assertSame(6, count($checks->getMissings()));
104 $html = $checks->toHtml();
105 $this->assertStringNotContainsString('green check icon', $html);
106 $this->assertSame(1026, strlen($html));
114 public function testToHtml()
116 $checks = new \Galette\Core\
CheckModules();
118 $html = $checks->toHtml();
119 $this->assertStringNotContainsString('icon-invalid.png', $html);
120 $this->assertGreaterThanOrEqual(908, strlen($html));