]> git.agnieray.net Git - galette.git/blob - tests/Galette/Core/tests/units/CheckModules.php
4767004adf07cf4fb0149001824a82464d1cd537
[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 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 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 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 * Test new PasswordImage generation
58 *
59 * @return void
60 */
61 public function testAllOK()
62 {
63 $checks = new \Galette\Core\CheckModules();
64 $this->boolean($checks->isValid())->isTrue();
65 $this->integer(count($checks->getGoods()))
66 ->isLessThanOrEqualTo(10)
67 ->isGreaterThanOrEqualTo(6);
68 $this->array($checks->getMissings())
69 ->isEmpty();
70 $this->array($checks->getShoulds())
71 ->isEmpty(2);
72 $this->boolean($checks->isGood('mbstring'))
73 ->isTrue();
74 }
75
76 /**
77 * Test all extensions missing
78 *
79 * @return void
80 */
81 public function testAllKO()
82 {
83 $this->assert('All PHP extensions missing')
84 ->given($checks = new \Galette\Core\CheckModules(false))
85 ->if($this->function->extension_loaded = false)
86 ->then
87 ->if($checks->doCheck())
88 ->then
89 ->array($checks->getGoods())
90 ->hasSize(0)
91 ->array($checks->getShoulds())
92 ->hasSize(4)
93 ->array($checks->getMissings())
94 ->hasSize(6)
95 ->string($checks->toHtml())
96 ->notContains('icon-valid.png')
97 ->hasLength(1141);
98 }
99
100 /**
101 * Test HTMl output
102 *
103 * @return void
104 */
105 public function testToHtml()
106 {
107 $checks = new \Galette\Core\CheckModules();
108 $checks->doCheck();
109 $html = $checks->toHtml();
110 $this->string($html)
111 ->notContains('icon-invalid.png')
112 ->length->isGreaterThanOrEqualTo(908);
113 }
114 }