Skip to content

Commit

Permalink
Merge [3398] and [3399].
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 9, 2008
1 parent 52149b2 commit ec7fbb1
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 28 deletions.
3 changes: 2 additions & 1 deletion PHPUnit/Framework.php
Expand Up @@ -52,7 +52,8 @@
require 'PHPUnit/Framework/AssertionFailedError.php';
require 'PHPUnit/Framework/Assert.php';
require 'PHPUnit/Framework/Error.php';
require 'PHPUnit/Framework/Notice.php';
require 'PHPUnit/Framework/Error/Notice.php';
require 'PHPUnit/Framework/Error/Warning.php';
require 'PHPUnit/Framework/IncompleteTest.php';
require 'PHPUnit/Framework/SkippedTest.php';
require 'PHPUnit/Framework/Test.php';
Expand Down
Expand Up @@ -41,21 +41,21 @@
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id$
* @link http://www.phpunit.de/
* @since File available since Release 3.1.0
* @since File available since Release 3.3.0
*/

require_once 'PHPUnit/Util/Filter.php';

PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');

if (!class_exists('PHPUnit_Framework_Notice', FALSE)) {
if (!class_exists('PHPUnit_Framework_Error_Notice', FALSE)) {

/**
* Wrapper for PHP notices.
* You can disable notice-to-exception conversion by setting
*
* <code>
* PHPUnit_Framework_Notice::$enabled = FALSE;
* PHPUnit_Framework_Error_Notice::$enabled = FALSE;
* </code>
*
* @category Testing
Expand All @@ -65,9 +65,9 @@
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version Release: @package_version@
* @link http://www.phpunit.de/
* @since Class available since Release 3.1.0
* @since Class available since Release 3.3.0
*/
class PHPUnit_Framework_Notice extends PHPUnit_Framework_Error
class PHPUnit_Framework_Error_Notice extends PHPUnit_Framework_Error
{
public static $enabled = TRUE;
}
Expand Down
76 changes: 76 additions & 0 deletions PHPUnit/Framework/Error/Warning.php
@@ -0,0 +1,76 @@
<?php
/**
* PHPUnit
*
* Copyright (c) 2002-2008, Sebastian Bergmann <sb@sebastian-bergmann.de>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Sebastian Bergmann nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category Testing
* @package PHPUnit
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2002-2008 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id$
* @link http://www.phpunit.de/
* @since File available since Release 3.3.0
*/

require_once 'PHPUnit/Util/Filter.php';

PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');

if (!class_exists('PHPUnit_Framework_Error_Warning', FALSE)) {

/**
* Wrapper for PHP warnings.
* You can disable notice-to-exception conversion by setting
*
* <code>
* PHPUnit_Framework_Error_Warning::$enabled = FALSE;
* </code>
*
* @category Testing
* @package PHPUnit
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2002-2008 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version Release: @package_version@
* @link http://www.phpunit.de/
* @since Class available since Release 3.3.0
*/
class PHPUnit_Framework_Error_Warning extends PHPUnit_Framework_Error
{
public static $enabled = TRUE;
}

}
?>
39 changes: 24 additions & 15 deletions PHPUnit/TextUI/TestRunner.php
Expand Up @@ -174,7 +174,11 @@ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
}

if (!$arguments['convertNoticesToExceptions']) {
PHPUnit_Framework_Notice::$enabled = FALSE;
PHPUnit_Framework_Error_Notice::$enabled = FALSE;
}

if (!$arguments['convertWarningsToExceptions']) {
PHPUnit_Framework_Error_Warning::$enabled = FALSE;
}

if ($arguments['stopOnFailure']) {
Expand Down Expand Up @@ -636,6 +640,10 @@ protected function handleConfiguration(array &$arguments)
$arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
}

if (isset($phpunitConfiguration['convertWarningsToExceptions']) && !isset($arguments['convertWarningsToExceptions'])) {
$arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
}

if (isset($phpunitConfiguration['stopOnFailure']) && !isset($arguments['stopOnFailure'])) {
$arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
}
Expand Down Expand Up @@ -752,20 +760,21 @@ protected function handleConfiguration(array &$arguments)
}
}

$arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5;
$arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70;
$arguments['ansi'] = isset($arguments['ansi']) ? $arguments['ansi'] : FALSE;
$arguments['convertErrorsToExceptions'] = isset($arguments['convertErrorsToExceptions']) ? $arguments['convertErrorsToExceptions'] : TRUE;
$arguments['convertNoticesToExceptions'] = isset($arguments['convertNoticesToExceptions']) ? $arguments['convertNoticesToExceptions'] : TRUE;
$arguments['excludeGroups'] = isset($arguments['excludeGroups']) ? $arguments['excludeGroups'] : array();
$arguments['groups'] = isset($arguments['groups']) ? $arguments['groups'] : array();
$arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE;
$arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'ISO-8859-1';
$arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE;
$arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70;
$arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35;
$arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE;
$arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE;
$arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5;
$arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70;
$arguments['ansi'] = isset($arguments['ansi']) ? $arguments['ansi'] : FALSE;
$arguments['convertErrorsToExceptions'] = isset($arguments['convertErrorsToExceptions']) ? $arguments['convertErrorsToExceptions'] : TRUE;
$arguments['convertNoticesToExceptions'] = isset($arguments['convertNoticesToExceptions']) ? $arguments['convertNoticesToExceptions'] : TRUE;
$arguments['convertWarningsToExceptions'] = isset($arguments['convertWarningsToExceptions']) ? $arguments['convertWarningsToExceptions'] : TRUE;
$arguments['excludeGroups'] = isset($arguments['excludeGroups']) ? $arguments['excludeGroups'] : array();
$arguments['groups'] = isset($arguments['groups']) ? $arguments['groups'] : array();
$arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE;
$arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'ISO-8859-1';
$arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE;
$arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70;
$arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35;
$arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE;
$arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE;
}
}
?>
9 changes: 8 additions & 1 deletion PHPUnit/Util/Configuration.php
Expand Up @@ -57,7 +57,7 @@
* <code>
* <?xml version="1.0" encoding="utf-8" ?>
*
* <phpunit ansi="false" convertErrorsToExceptions="true" convertNoticesToExceptions="true" stopOnFailure="false">
* <phpunit ansi="false" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnFailure="false">
* <testsuite name="My Test Suite">
* <directory suffix="Test.php">/path/to/files</directory>
* <file>/path/to/MyTest.php</file>
Expand Down Expand Up @@ -411,6 +411,13 @@ public function getPHPUnitConfiguration()
);
}

if ($this->document->documentElement->hasAttribute('convertWarningsToExceptions')) {
$result['convertWarningsToExceptions'] = $this->getBoolean(
(string)$this->document->documentElement->getAttribute('convertWarningsToExceptions'),
TRUE
);
}

if ($this->document->documentElement->hasAttribute('stopOnFailure')) {
$result['stopOnFailure'] = $this->getBoolean(
(string)$this->document->documentElement->getAttribute('stopOnFailure'),
Expand Down
16 changes: 13 additions & 3 deletions PHPUnit/Util/ErrorHandler.php
Expand Up @@ -100,12 +100,22 @@ public static function handleError($errno, $errstr, $errfile, $errline)
}

if ($errno == E_NOTICE || $errno == E_STRICT) {
if (PHPUnit_Framework_Notice::$enabled !== TRUE) {
if (PHPUnit_Framework_Error_Notice::$enabled !== TRUE) {
return FALSE;
}

$exception = 'PHPUnit_Framework_Notice';
} else {
$exception = 'PHPUnit_Framework_Error_Notice';
}

else if ($errno == E_WARNING) {
if (PHPUnit_Framework_Error_Warning::$enabled !== TRUE) {
return FALSE;
}

$exception = 'PHPUnit_Framework_Error_Warning';
}

else {
$exception = 'PHPUnit_Framework_Error';
}

Expand Down
11 changes: 8 additions & 3 deletions package.xml
Expand Up @@ -383,6 +383,14 @@
<tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
</dir>
<dir name="Error">
<file baseinstalldir="/" name="Notice.php" role="php">
<tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
<file baseinstalldir="/" name="Warning.php" role="php">
<tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
</dir>
<dir name="MockObject">
<dir name="Builder">
<file baseinstalldir="/" name="Identity.php" role="php">
Expand Down Expand Up @@ -508,9 +516,6 @@
<file baseinstalldir="/" name="IncompleteTest.php" role="php">
<tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
<file baseinstalldir="/" name="Notice.php" role="php">
<tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
<file baseinstalldir="/" name="SelfDescribing.php" role="php">
<tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
Expand Down

0 comments on commit ec7fbb1

Please sign in to comment.