]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/PHPUnit/Tests/Util/ConfigurationTest.php
Added unit tests.
[Github/sugarcrm.git] / tests / PHPUnit / Tests / Util / ConfigurationTest.php
1 <?php
2 /**
3  * PHPUnit
4  *
5  * Copyright (c) 2002-2009, Sebastian Bergmann <sb@sebastian-bergmann.de>.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  *   * Redistributions of source code must retain the above copyright
13  *     notice, this list of conditions and the following disclaimer.
14  *
15  *   * Redistributions in binary form must reproduce the above copyright
16  *     notice, this list of conditions and the following disclaimer in
17  *     the documentation and/or other materials provided with the
18  *     distribution.
19  *
20  *   * Neither the name of Sebastian Bergmann nor the names of his
21  *     contributors may be used to endorse or promote products derived
22  *     from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * @category   Testing
38  * @package    PHPUnit
39  * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
40  * @copyright  2002-2009 Sebastian Bergmann <sb@sebastian-bergmann.de>
41  * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
42
43  * @link       http://www.phpunit.de/
44  * @since      File available since Release 3.3.0
45  */
46
47 require_once 'PHPUnit/Framework/TestCase.php';
48
49 require_once 'PHPUnit/Util/Configuration.php';
50
51 /**
52  *
53  *
54  * @category   Testing
55  * @package    PHPUnit
56  * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
57  * @copyright  2002-2009 Sebastian Bergmann <sb@sebastian-bergmann.de>
58  * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
59  * @version    Release: 3.3.17
60  * @link       http://www.phpunit.de/
61  * @since      Class available since Release 3.3.0
62  */
63 class Util_ConfigurationTest extends PHPUnit_Framework_TestCase
64 {
65     protected $configuration;
66
67     protected function setUp()
68     {
69         $this->configuration = new PHPUnit_Util_Configuration(
70           dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'configuration.xml'
71         );
72     }
73
74     public function testGetFilterConfiguration()
75     {
76         $this->assertEquals(
77           array (
78             'blacklist' =>
79             array (
80               'include' =>
81               array (
82                 'directory' =>
83                 array (
84                   0 =>
85                   array (
86                     'path' => '/path/to/files',
87                     'suffix' => '.php',
88                   ),
89                 ),
90                 'file' =>
91                 array (
92                   0 => '/path/to/file',
93                 ),
94               ),
95               'exclude' =>
96               array (
97                 'directory' =>
98                 array (
99                   0 =>
100                   array (
101                     'path' => '/path/to/files',
102                     'suffix' => '.php',
103                   ),
104                 ),
105                 'file' =>
106                 array (
107                   0 => '/path/to/file',
108                 ),
109               ),
110             ),
111             'whitelist' =>
112             array (
113               'addUncoveredFilesFromWhitelist' => TRUE,
114               'include' =>
115               array (
116                 'directory' =>
117                 array (
118                   0 =>
119                   array (
120                     'path' => '/path/to/files',
121                     'suffix' => '.php',
122                   ),
123                 ),
124                 'file' =>
125                 array (
126                   0 => '/path/to/file',
127                 ),
128               ),
129               'exclude' =>
130               array (
131                 'directory' =>
132                 array (
133                   0 =>
134                   array (
135                     'path' => '/path/to/files',
136                     'suffix' => '.php',
137                   ),
138                 ),
139                 'file' =>
140                 array (
141                   0 => '/path/to/file',
142                 ),
143               ),
144             ),
145           ),
146           $this->configuration->getFilterConfiguration()
147         );
148     }
149
150     public function testGetGroupConfiguration()
151     {
152         $this->assertEquals(
153           array (
154             'include' =>
155             array (
156               0 => 'name',
157             ),
158             'exclude' =>
159             array (
160               0 => 'name',
161             ),
162           ),
163           $this->configuration->getGroupConfiguration()
164         );
165     }
166
167     public function testGetLoggingConfiguration()
168     {
169         $this->assertEquals(
170           array (
171             'charset' => 'UTF-8',
172             'lowUpperBound' => '35',
173             'highLowerBound' => '70',
174             'yui' => TRUE,
175             'highlight' => FALSE,
176             'coverage-html' => '/tmp/report',
177             'coverage-clover' => '/tmp/clover.xml',
178             'coverage-source' => '/tmp/coverage',
179             'graphviz' => '/tmp/logfile.dot',
180             'json' => '/tmp/logfile.json',
181             'metrics-xml' => '/tmp/metrics.xml',
182             'plain' => '/tmp/logfile.txt',
183             'cpdMinLines' => '5',
184             'cpdMinMatches' => '70',
185             'pmd-xml' => '/tmp/pmd.xml',
186             'tap' => '/tmp/logfile.tap',
187             'logIncompleteSkipped' => FALSE,
188             'test-xml' => '/tmp/logfile.xml',
189             'story-html' => '/tmp/story.html',
190             'story-text' => '/tmp/story.txt',
191             'testdox-html' => '/tmp/testdox.html',
192             'testdox-text' => '/tmp/testdox.txt',
193           ),
194           $this->configuration->getLoggingConfiguration()
195         );
196     }
197
198     public function testGetPHPConfiguration()
199     {
200         $this->assertEquals(
201           array (
202             'ini' =>
203             array (
204               'foo' => 'bar',
205             ),
206             'var' =>
207             array (
208               'foo' => 'bar',
209             ),
210           ),
211           $this->configuration->getPHPConfiguration()
212         );
213     }
214
215     public function testGetPHPUnitConfiguration()
216     {
217         $this->assertEquals(
218           array (
219             'bootstrap' => '/path/to/bootstrap.php',
220             'colors' => FALSE,
221             'convertErrorsToExceptions' => TRUE,
222             'convertNoticesToExceptions' => TRUE,
223             'convertWarningsToExceptions' => TRUE,
224             'stopOnFailure' => FALSE,
225           ),
226           $this->configuration->getPHPUnitConfiguration()
227         );
228     }
229
230     public function testGetPMDConfiguration()
231     {
232         $this->assertEquals(
233           array (
234             'PHPUnit_Util_Log_PMD_Rule_Project_CRAP' =>
235             array (
236               'threshold' =>
237               array (
238                 0 => '5',
239                 1 => '30',
240               ),
241               'priority' => 1,
242             ),
243             'PHPUnit_Util_Log_PMD_Rule_Class_DepthOfInheritanceTree' =>
244             array (
245               'threshold' => '6',
246               'priority' => 1,
247             ),
248             'PHPUnit_Util_Log_PMD_Rule_Class_EfferentCoupling' =>
249             array (
250               'threshold' => '20',
251               'priority' => 1,
252             ),
253             'PHPUnit_Util_Log_PMD_Rule_Class_ExcessiveClassLength' =>
254             array (
255               'threshold' => '1000',
256               'priority' => 1,
257             ),
258             'PHPUnit_Util_Log_PMD_Rule_Class_ExcessivePublicCount' =>
259             array (
260               'threshold' => '45',
261               'priority' => 1,
262             ),
263             'PHPUnit_Util_Log_PMD_Rule_Class_TooManyFields' =>
264             array (
265               'threshold' => '15',
266               'priority' => 1,
267             ),
268             'PHPUnit_Util_Log_PMD_Rule_Function_CodeCoverage' =>
269             array (
270               'threshold' =>
271               array (
272                 0 => '35',
273                 1 => '70',
274               ),
275               'priority' => 1,
276             ),
277             'PHPUnit_Util_Log_PMD_Rule_Function_CRAP' =>
278             array (
279               'threshold' => '30',
280               'priority' => 1,
281             ),
282             'PHPUnit_Util_Log_PMD_Rule_Function_CyclomaticComplexity' =>
283             array (
284               'threshold' => '20',
285               'priority' => 1,
286             ),
287             'PHPUnit_Util_Log_PMD_Rule_Function_ExcessiveMethodLength' =>
288             array (
289               'threshold' => '100',
290               'priority' => 1,
291             ),
292             'PHPUnit_Util_Log_PMD_Rule_Function_ExcessiveParameterList' =>
293             array (
294               'threshold' => '10',
295               'priority' => 1,
296             ),
297             'PHPUnit_Util_Log_PMD_Rule_Function_NPathComplexity' =>
298             array (
299               'threshold' => '200',
300               'priority' => 1,
301             ),
302           ),
303           $this->configuration->getPMDConfiguration()
304         );
305     }
306
307     public function testGetSeleniumBrowserConfiguration()
308     {
309         $this->assertEquals(
310           array (
311             0 =>
312             array (
313               'name' => 'Firefox on Linux',
314               'browser' => '*firefox /usr/lib/firefox/firefox-bin',
315               'host' => 'my.linux.box',
316               'port' => 4444,
317               'timeout' => 30000,
318             ),
319           ),
320           $this->configuration->getSeleniumBrowserConfiguration()
321         );
322     }
323 }
324 ?>