]> git.agnieray.net Git - galette.git/blob - tests/Galette/Core/tests/units/CheckModules.php
2959764d5b11c3b5a2af1d18f45d7fc7737727d2
[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 atoum;
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 atoum
55 {
56 /**
57 * Tear down tests
58 *
59 * @param string $method Calling method
60 *
61 * @return void
62 */
63 public function afterTestMethod($method)
64 {
65 if (TYPE_DB === 'mysql') {
66 $zdb = new \Galette\Core\Db();
67 $this->array($zdb->getWarnings())->isIdenticalTo([]);
68 }
69 }
70
71 /**
72 * Test modules, all should be ok
73 *
74 * @return void
75 */
76 public function testAllOK()
77 {
78 $checks = new \Galette\Core\CheckModules();
79 $this->boolean($checks->isValid())->isTrue();
80 $this->integer(count($checks->getGoods()))
81 ->isLessThanOrEqualTo(10)
82 ->isGreaterThanOrEqualTo(6);
83 $this->array($checks->getMissings())
84 ->isEmpty();
85 $this->array($checks->getShoulds())
86 ->isEmpty();
87 $this->boolean($checks->isGood('mbstring'))
88 ->isTrue();
89 }
90
91 /**
92 * Test all extensions missing
93 *
94 * @return void
95 */
96 public function testAllKO()
97 {
98 $this->assert('All PHP extensions missing')
99 ->given($checks = new \Galette\Core\CheckModules(false))
100 ->if($this->function->extension_loaded = false)
101 ->then
102 ->if($checks->doCheck())
103 ->then
104 ->array($checks->getGoods())
105 ->hasSize(0)
106 ->array($checks->getShoulds())
107 ->hasSize(3)
108 ->array($checks->getMissings())
109 ->hasSize(6)
110 ->string($checks->toHtml())
111 ->notContains('green check icon')
112 ->hasLength(1026);
113 }
114
115 /**
116 * Test HTMl output
117 *
118 * @return void
119 */
120 public function testToHtml()
121 {
122 $checks = new \Galette\Core\CheckModules();
123 $checks->doCheck();
124 $html = $checks->toHtml();
125 $this->string($html)
126 ->notContains('icon-invalid.png')
127 ->length->isGreaterThanOrEqualTo(908);
128 }
129 }