cvs: pear /Services_Akismet/tests TestCase.php
[email protected] ("Michael Gauthier") Thu, 08 May 2008 13:45:45 -0000
| Newsgroups | php.pear.cvs |
|---|---|
| Message-ID | <cvsgauthierm1210254345@cvsserver> |
gauthierm Thu May 8 13:45:45 2008 UTC
Modified files:
/pear/Services_Akismet/tests TestCase.php
Log:
Skip unit tests if config is not available rather than failing if config is not available.
http://cvs.php.net/viewvc.cgi/pear/Services_Akismet/tests/TestCase.php?r1=1.2&r2=1.3&diff_format=u
Index: pear/Services_Akismet/tests/TestCase.php
diff -u pear/Services_Akismet/tests/TestCase.php:1.2 pear/Services_Akismet/tests/TestCase.php:1.3
--- pear/Services_Akismet/tests/TestCase.php:1.2 Sun May 4 00:21:48 2008
+++ pear/Services_Akismet/tests/TestCase.php Thu May 8 13:45:45 2008
@@ -38,7 +38,7 @@
* @author Michael Gauthier <[email protected]>
* @copyright 2008 silverorange
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
- * @version CVS: $Id: TestCase.php,v 1.2 2008/05/04 00:21:48 gauthierm Exp $
+ * @version CVS: $Id: TestCase.php,v 1.3 2008/05/08 13:45:45 gauthierm Exp $
* @link http://pear.php.net/package/Services_Akismet
*/
@@ -84,28 +84,13 @@
*/
protected $akismet = null;
- /**
- * @var array
- */
- protected $config = array();
-
// }}}
// {{{ __construct()
public function __construct($name = null)
{
parent::__construct($name);
-
- if (!file_exists(dirname(__FILE__).'/config.php')) {
- throw new Exception('Unit test configuration file is missing. ' .
- 'Please read the documentation in TestCase.php and create ' .
- 'a configuration file. See the example configuration provided '.
- 'in config.php.dist for an example.');
- }
-
- include_once dirname(__FILE__).'/config.php';
-
- $this->config = $GLOBALS['Services_Akismet_Unittest_Config'];
+ @include_once dirname(__FILE__).'/config.php';
}
// }}}
@@ -113,9 +98,22 @@
public function setUp()
{
+ if (!is_array($GLOBALS['Services_Akismet_Unittest_Config'])) {
+ $this->markTestSkipped('Unit test configuration is missing.');
+ }
+
+ if ( !isset($GLOBALS['Services_Akismet_Unittest_Config']['blogUri'])
+ || !isset($GLOBALS['Services_Akismet_Unittest_Config']['apiKey'])
+ ) {
+ $this->markTestSkipped('Unit test configuration is missing or.' .
+ 'incorrect.');
+ }
+
$this->_oldErrorLevel = error_reporting(E_ALL | E_STRICT);
+
$this->akismet = new Services_Akismet(
- $this->config['blogUri'], $this->config['apiKey'],
+ $GLOBALS['Services_Akismet_Unittest_Config']['blogUri'],
+ $GLOBALS['Services_Akismet_Unittest_Config']['apiKey'],
$this->getHttpClientImplementation());
}
@@ -208,7 +206,8 @@
public function testInvalidApiKeyException()
{
$badApiKey = 'asdf';
- $akismet = new Services_Akismet($this->config['blogUri'],
+ $akismet = new Services_Akismet(
+ $GLOBALS['Services_Akismet_Unittest_Config']['blogUri'],
$badApiKey, $this->getHttpClientImplementation());
}