]> git.agnieray.net Git - galette.git/blob - tests/Galette/Core/tests/units/CheckModules.php
305da30d3d16c55ecf8a968e167e025ae84383ca
[galette.git] / tests / Galette / Core / tests / units / CheckModules.php
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * CheckModules tests
7 *
8 * PHP version 5
9 *
10 * Copyright © 2016-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 Core
28 * @package GaletteTests
29 *
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
33 * @version SVN: $Id$
34 * @link http://galette.tuxfamily.org
35 * @since 2016-11-09
36 */
37
38 namespace Galette\Core\test\units;
39
40 use PHPUnit\Framework\TestCase;
41
42 /**
43 * CheckModules tests class
44 *
45 * @category Core
46 * @name CheckModules
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
52 * @since 2016-11-09
53 */
54 class CheckModules extends TestCase
55 {
56 /**
57 * Tear down tests
58 *
59 * @return void
60 */
61 public function tearDown(): void
62 {
63 if (TYPE_DB === 'mysql') {
64 $zdb = new \Galette\Core\Db();
65 $this->assertSame([], $zdb->getWarnings());
66 }
67 parent::tearDown();
68 }
69
70 /**
71 * Test modules, all should be ok
72 *
73 * @return void
74 */
75 public function testAllOK()
76 {
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'));
84 }
85
86 /**
87 * Test all extensions missing
88 *
89 * @return void
90 */
91 public function testAllKO()
92 {
93 $checks = $this->getMockBuilder(\Galette\Core\CheckModules::class)
94 ->setConstructorArgs([false])
95 ->onlyMethods(array('isExtensionLoaded'))
96 ->getMock();
97 $checks->method('isExtensionLoaded')->willReturn(false);
98
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()));
103
104 $html = $checks->toHtml();
105 $this->assertStringNotContainsString('green check icon', $html);
106 $this->assertSame(1026, strlen($html));
107 }
108
109 /**
110 * Test HTMl output
111 *
112 * @return void
113 */
114 public function testToHtml()
115 {
116 $checks = new \Galette\Core\CheckModules();
117 $checks->doCheck();
118 $html = $checks->toHtml();
119 $this->assertStringNotContainsString('icon-invalid.png', $html);
120 $this->assertGreaterThanOrEqual(908, strlen($html));
121 }
122 }