PageRenderTime 56ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/phpunit/3.4.0/PHPUnit/Tests/Util/ConfigurationTest.php

https://github.com/vivid-planet/library
PHP | 367 lines | 299 code | 12 blank | 56 comment | 0 complexity | c54175767f84a7014c9b7cc9e6785780 MD5 | raw file
  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. * @version SVN: $Id: ConfigurationTest.php 5078 2009-08-10 07:58:18Z sb $
  43. * @link http://www.phpunit.de/
  44. * @since File available since Release 3.3.0
  45. */
  46. require_once 'PHPUnit/Framework/TestCase.php';
  47. require_once 'PHPUnit/Util/Configuration.php';
  48. /**
  49. *
  50. *
  51. * @category Testing
  52. * @package PHPUnit
  53. * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
  54. * @copyright 2002-2009 Sebastian Bergmann <sb@sebastian-bergmann.de>
  55. * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  56. * @version Release: @package_version@
  57. * @link http://www.phpunit.de/
  58. * @since Class available since Release 3.3.0
  59. */
  60. class Util_ConfigurationTest extends PHPUnit_Framework_TestCase
  61. {
  62. protected $configuration;
  63. protected function setUp()
  64. {
  65. $this->configuration = PHPUnit_Util_Configuration::getInstance(
  66. dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'configuration.xml'
  67. );
  68. }
  69. public function testGetFilterConfiguration()
  70. {
  71. $this->assertEquals(
  72. array (
  73. 'blacklist' =>
  74. array (
  75. 'include' =>
  76. array (
  77. 'directory' =>
  78. array (
  79. 0 =>
  80. array (
  81. 'path' => '/path/to/files',
  82. 'prefix' => '',
  83. 'suffix' => '.php',
  84. 'group' => 'DEFAULT'
  85. ),
  86. ),
  87. 'file' =>
  88. array (
  89. 0 => '/path/to/file',
  90. ),
  91. ),
  92. 'exclude' =>
  93. array (
  94. 'directory' =>
  95. array (
  96. 0 =>
  97. array (
  98. 'path' => '/path/to/files',
  99. 'prefix' => '',
  100. 'suffix' => '.php',
  101. 'group' => 'DEFAULT'
  102. ),
  103. ),
  104. 'file' =>
  105. array (
  106. 0 => '/path/to/file',
  107. ),
  108. ),
  109. ),
  110. 'whitelist' =>
  111. array (
  112. 'addUncoveredFilesFromWhitelist' => TRUE,
  113. 'include' =>
  114. array (
  115. 'directory' =>
  116. array (
  117. 0 =>
  118. array (
  119. 'path' => '/path/to/files',
  120. 'prefix' => '',
  121. 'suffix' => '.php',
  122. 'group' => 'DEFAULT'
  123. ),
  124. ),
  125. 'file' =>
  126. array (
  127. 0 => '/path/to/file',
  128. ),
  129. ),
  130. 'exclude' =>
  131. array (
  132. 'directory' =>
  133. array (
  134. 0 =>
  135. array (
  136. 'path' => '/path/to/files',
  137. 'prefix' => '',
  138. 'suffix' => '.php',
  139. 'group' => 'DEFAULT'
  140. ),
  141. ),
  142. 'file' =>
  143. array (
  144. 0 => '/path/to/file',
  145. ),
  146. ),
  147. ),
  148. ),
  149. $this->configuration->getFilterConfiguration()
  150. );
  151. }
  152. public function testGetGroupConfiguration()
  153. {
  154. $this->assertEquals(
  155. array (
  156. 'include' =>
  157. array (
  158. 0 => 'name',
  159. ),
  160. 'exclude' =>
  161. array (
  162. 0 => 'name',
  163. ),
  164. ),
  165. $this->configuration->getGroupConfiguration()
  166. );
  167. }
  168. public function testGetListenerConfiguration()
  169. {
  170. $this->assertEquals(
  171. array (
  172. 0 =>
  173. array (
  174. 'class' => 'MyListener',
  175. 'file' => '/optional/path/to/MyListener.php',
  176. 'arguments' =>
  177. array (
  178. 0 =>
  179. array (
  180. 0 => 'Sebastian',
  181. ),
  182. 1 => 22,
  183. 2 => 'April',
  184. 3 => 19.78,
  185. 4 => NULL,
  186. 5 => new stdClass,
  187. ),
  188. ),
  189. ),
  190. $this->configuration->getListenerConfiguration()
  191. );
  192. }
  193. public function testGetLoggingConfiguration()
  194. {
  195. $this->assertEquals(
  196. array (
  197. 'title' => 'My Project',
  198. 'charset' => 'UTF-8',
  199. 'lowUpperBound' => '35',
  200. 'highLowerBound' => '70',
  201. 'yui' => TRUE,
  202. 'highlight' => FALSE,
  203. 'coverage-html' => '/tmp/report',
  204. 'coverage-clover' => '/tmp/clover.xml',
  205. 'coverage-source' => '/tmp/coverage',
  206. 'graphviz' => '/tmp/logfile.dot',
  207. 'json' => '/tmp/logfile.json',
  208. 'metrics-xml' => '/tmp/metrics.xml',
  209. 'plain' => '/tmp/logfile.txt',
  210. 'cpdMinLines' => '5',
  211. 'cpdMinMatches' => '70',
  212. 'pmd-xml' => '/tmp/pmd.xml',
  213. 'tap' => '/tmp/logfile.tap',
  214. 'logIncompleteSkipped' => FALSE,
  215. 'junit' => '/tmp/logfile.xml',
  216. 'story-html' => '/tmp/story.html',
  217. 'story-text' => '/tmp/story.txt',
  218. 'testdox-html' => '/tmp/testdox.html',
  219. 'testdox-text' => '/tmp/testdox.txt',
  220. ),
  221. $this->configuration->getLoggingConfiguration()
  222. );
  223. }
  224. public function testGetPHPConfiguration()
  225. {
  226. $this->assertEquals(
  227. array (
  228. 'ini' =>
  229. array (
  230. 'foo' => 'bar',
  231. ),
  232. 'const' =>
  233. array (
  234. 'foo' => 'bar',
  235. ),
  236. 'var' =>
  237. array (
  238. 'foo' => 'bar',
  239. ),
  240. ),
  241. $this->configuration->getPHPConfiguration()
  242. );
  243. }
  244. public function testGetPHPUnitConfiguration()
  245. {
  246. $this->assertEquals(
  247. array (
  248. 'backupGlobals' => TRUE,
  249. 'backupStaticAttributes' => TRUE,
  250. 'bootstrap' => '/path/to/bootstrap.php',
  251. 'colors' => FALSE,
  252. 'convertErrorsToExceptions' => TRUE,
  253. 'convertNoticesToExceptions' => TRUE,
  254. 'convertWarningsToExceptions' => TRUE,
  255. 'stopOnFailure' => FALSE,
  256. 'syntaxCheck' => FALSE,
  257. 'testSuiteLoaderClass' => 'PHPUnit_Runner_StandardTestSuiteLoader'
  258. ),
  259. $this->configuration->getPHPUnitConfiguration()
  260. );
  261. }
  262. public function testGetPMDConfiguration()
  263. {
  264. $this->assertEquals(
  265. array (
  266. 'PHPUnit_Util_Log_PMD_Rule_Project_CRAP' =>
  267. array (
  268. 'threshold' =>
  269. array (
  270. 0 => '5',
  271. 1 => '30',
  272. ),
  273. 'priority' => 1,
  274. ),
  275. 'PHPUnit_Util_Log_PMD_Rule_Class_DepthOfInheritanceTree' =>
  276. array (
  277. 'threshold' => '6',
  278. 'priority' => 1,
  279. ),
  280. 'PHPUnit_Util_Log_PMD_Rule_Class_EfferentCoupling' =>
  281. array (
  282. 'threshold' => '20',
  283. 'priority' => 1,
  284. ),
  285. 'PHPUnit_Util_Log_PMD_Rule_Class_ExcessiveClassLength' =>
  286. array (
  287. 'threshold' => '1000',
  288. 'priority' => 1,
  289. ),
  290. 'PHPUnit_Util_Log_PMD_Rule_Class_ExcessivePublicCount' =>
  291. array (
  292. 'threshold' => '45',
  293. 'priority' => 1,
  294. ),
  295. 'PHPUnit_Util_Log_PMD_Rule_Class_TooManyFields' =>
  296. array (
  297. 'threshold' => '15',
  298. 'priority' => 1,
  299. ),
  300. 'PHPUnit_Util_Log_PMD_Rule_Function_CodeCoverage' =>
  301. array (
  302. 'threshold' =>
  303. array (
  304. 0 => '35',
  305. 1 => '70',
  306. ),
  307. 'priority' => 1,
  308. ),
  309. 'PHPUnit_Util_Log_PMD_Rule_Function_CRAP' =>
  310. array (
  311. 'threshold' => '30',
  312. 'priority' => 1,
  313. ),
  314. 'PHPUnit_Util_Log_PMD_Rule_Function_CyclomaticComplexity' =>
  315. array (
  316. 'threshold' => '20',
  317. 'priority' => 1,
  318. ),
  319. 'PHPUnit_Util_Log_PMD_Rule_Function_ExcessiveMethodLength' =>
  320. array (
  321. 'threshold' => '100',
  322. 'priority' => 1,
  323. ),
  324. 'PHPUnit_Util_Log_PMD_Rule_Function_ExcessiveParameterList' =>
  325. array (
  326. 'threshold' => '10',
  327. 'priority' => 1,
  328. ),
  329. 'PHPUnit_Util_Log_PMD_Rule_Function_NPathComplexity' =>
  330. array (
  331. 'threshold' => '200',
  332. 'priority' => 1,
  333. ),
  334. ),
  335. $this->configuration->getPMDConfiguration()
  336. );
  337. }
  338. public function testGetSeleniumBrowserConfiguration()
  339. {
  340. $this->assertEquals(
  341. array (
  342. 0 =>
  343. array (
  344. 'name' => 'Firefox on Linux',
  345. 'browser' => '*firefox /usr/lib/firefox/firefox-bin',
  346. 'host' => 'my.linux.box',
  347. 'port' => 4444,
  348. 'timeout' => 30000,
  349. ),
  350. ),
  351. $this->configuration->getSeleniumBrowserConfiguration()
  352. );
  353. }
  354. }
  355. ?>