Skip to content
This repository
Browse code

- Merge [3398] and [3399].

  • Loading branch information...
commit 47a883389ada9a5992e271f2801c2ebf9249302b 1 parent ab2eb21
Sebastian Bergmann authored
3  PHPUnit/Framework.php
@@ -52,7 +52,8 @@
52 52 require 'PHPUnit/Framework/AssertionFailedError.php';
53 53 require 'PHPUnit/Framework/Assert.php';
54 54 require 'PHPUnit/Framework/Error.php';
55   -require 'PHPUnit/Framework/Notice.php';
  55 +require 'PHPUnit/Framework/Error/Notice.php';
  56 +require 'PHPUnit/Framework/Error/Warning.php';
56 57 require 'PHPUnit/Framework/IncompleteTest.php';
57 58 require 'PHPUnit/Framework/SkippedTest.php';
58 59 require 'PHPUnit/Framework/Test.php';
10 PHPUnit/Framework/Notice.php → PHPUnit/Framework/Error/Notice.php
@@ -41,21 +41,21 @@
41 41 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
42 42 * @version SVN: $Id$
43 43 * @link http://www.phpunit.de/
44   - * @since File available since Release 3.1.0
  44 + * @since File available since Release 3.3.0
45 45 */
46 46
47 47 require_once 'PHPUnit/Util/Filter.php';
48 48
49 49 PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
50 50
51   -if (!class_exists('PHPUnit_Framework_Notice', FALSE)) {
  51 +if (!class_exists('PHPUnit_Framework_Error_Notice', FALSE)) {
52 52
53 53 /**
54 54 * Wrapper for PHP notices.
55 55 * You can disable notice-to-exception conversion by setting
56 56 *
57 57 * <code>
58   - * PHPUnit_Framework_Notice::$enabled = FALSE;
  58 + * PHPUnit_Framework_Error_Notice::$enabled = FALSE;
59 59 * </code>
60 60 *
61 61 * @category Testing
@@ -65,9 +65,9 @@
65 65 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
66 66 * @version Release: @package_version@
67 67 * @link http://www.phpunit.de/
68   - * @since Class available since Release 3.1.0
  68 + * @since Class available since Release 3.3.0
69 69 */
70   -class PHPUnit_Framework_Notice extends PHPUnit_Framework_Error
  70 +class PHPUnit_Framework_Error_Notice extends PHPUnit_Framework_Error
71 71 {
72 72 public static $enabled = TRUE;
73 73 }
76 PHPUnit/Framework/Error/Warning.php
... ... @@ -0,0 +1,76 @@
  1 +<?php
  2 +/**
  3 + * PHPUnit
  4 + *
  5 + * Copyright (c) 2002-2008, 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-2008 Sebastian Bergmann <sb@sebastian-bergmann.de>
  41 + * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  42 + * @version SVN: $Id$
  43 + * @link http://www.phpunit.de/
  44 + * @since File available since Release 3.3.0
  45 + */
  46 +
  47 +require_once 'PHPUnit/Util/Filter.php';
  48 +
  49 +PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
  50 +
  51 +if (!class_exists('PHPUnit_Framework_Error_Warning', FALSE)) {
  52 +
  53 +/**
  54 + * Wrapper for PHP warnings.
  55 + * You can disable notice-to-exception conversion by setting
  56 + *
  57 + * <code>
  58 + * PHPUnit_Framework_Error_Warning::$enabled = FALSE;
  59 + * </code>
  60 + *
  61 + * @category Testing
  62 + * @package PHPUnit
  63 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
  64 + * @copyright 2002-2008 Sebastian Bergmann <sb@sebastian-bergmann.de>
  65 + * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  66 + * @version Release: @package_version@
  67 + * @link http://www.phpunit.de/
  68 + * @since Class available since Release 3.3.0
  69 + */
  70 +class PHPUnit_Framework_Error_Warning extends PHPUnit_Framework_Error
  71 +{
  72 + public static $enabled = TRUE;
  73 +}
  74 +
  75 +}
  76 +?>
39 PHPUnit/TextUI/TestRunner.php
@@ -174,7 +174,11 @@ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
174 174 }
175 175
176 176 if (!$arguments['convertNoticesToExceptions']) {
177   - PHPUnit_Framework_Notice::$enabled = FALSE;
  177 + PHPUnit_Framework_Error_Notice::$enabled = FALSE;
  178 + }
  179 +
  180 + if (!$arguments['convertWarningsToExceptions']) {
  181 + PHPUnit_Framework_Error_Warning::$enabled = FALSE;
178 182 }
179 183
180 184 if ($arguments['stopOnFailure']) {
@@ -636,6 +640,10 @@ protected function handleConfiguration(array &$arguments)
636 640 $arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
637 641 }
638 642
  643 + if (isset($phpunitConfiguration['convertWarningsToExceptions']) && !isset($arguments['convertWarningsToExceptions'])) {
  644 + $arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
  645 + }
  646 +
639 647 if (isset($phpunitConfiguration['stopOnFailure']) && !isset($arguments['stopOnFailure'])) {
640 648 $arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
641 649 }
@@ -752,20 +760,21 @@ protected function handleConfiguration(array &$arguments)
752 760 }
753 761 }
754 762
755   - $arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5;
756   - $arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70;
757   - $arguments['ansi'] = isset($arguments['ansi']) ? $arguments['ansi'] : FALSE;
758   - $arguments['convertErrorsToExceptions'] = isset($arguments['convertErrorsToExceptions']) ? $arguments['convertErrorsToExceptions'] : TRUE;
759   - $arguments['convertNoticesToExceptions'] = isset($arguments['convertNoticesToExceptions']) ? $arguments['convertNoticesToExceptions'] : TRUE;
760   - $arguments['excludeGroups'] = isset($arguments['excludeGroups']) ? $arguments['excludeGroups'] : array();
761   - $arguments['groups'] = isset($arguments['groups']) ? $arguments['groups'] : array();
762   - $arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE;
763   - $arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'ISO-8859-1';
764   - $arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE;
765   - $arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70;
766   - $arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35;
767   - $arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE;
768   - $arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE;
  763 + $arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5;
  764 + $arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70;
  765 + $arguments['ansi'] = isset($arguments['ansi']) ? $arguments['ansi'] : FALSE;
  766 + $arguments['convertErrorsToExceptions'] = isset($arguments['convertErrorsToExceptions']) ? $arguments['convertErrorsToExceptions'] : TRUE;
  767 + $arguments['convertNoticesToExceptions'] = isset($arguments['convertNoticesToExceptions']) ? $arguments['convertNoticesToExceptions'] : TRUE;
  768 + $arguments['convertWarningsToExceptions'] = isset($arguments['convertWarningsToExceptions']) ? $arguments['convertWarningsToExceptions'] : TRUE;
  769 + $arguments['excludeGroups'] = isset($arguments['excludeGroups']) ? $arguments['excludeGroups'] : array();
  770 + $arguments['groups'] = isset($arguments['groups']) ? $arguments['groups'] : array();
  771 + $arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE;
  772 + $arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'ISO-8859-1';
  773 + $arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE;
  774 + $arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70;
  775 + $arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35;
  776 + $arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE;
  777 + $arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE;
769 778 }
770 779 }
771 780 ?>
9 PHPUnit/Util/Configuration.php
@@ -57,7 +57,7 @@
57 57 * <code>
58 58 * <?xml version="1.0" encoding="utf-8" ?>
59 59 *
60   - * <phpunit ansi="false" convertErrorsToExceptions="true" convertNoticesToExceptions="true" stopOnFailure="false">
  60 + * <phpunit ansi="false" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnFailure="false">
61 61 * <testsuite name="My Test Suite">
62 62 * <directory suffix="Test.php">/path/to/files</directory>
63 63 * <file>/path/to/MyTest.php</file>
@@ -411,6 +411,13 @@ public function getPHPUnitConfiguration()
411 411 );
412 412 }
413 413
  414 + if ($this->document->documentElement->hasAttribute('convertWarningsToExceptions')) {
  415 + $result['convertWarningsToExceptions'] = $this->getBoolean(
  416 + (string)$this->document->documentElement->getAttribute('convertWarningsToExceptions'),
  417 + TRUE
  418 + );
  419 + }
  420 +
414 421 if ($this->document->documentElement->hasAttribute('stopOnFailure')) {
415 422 $result['stopOnFailure'] = $this->getBoolean(
416 423 (string)$this->document->documentElement->getAttribute('stopOnFailure'),
16 PHPUnit/Util/ErrorHandler.php
@@ -100,12 +100,22 @@ public static function handleError($errno, $errstr, $errfile, $errline)
100 100 }
101 101
102 102 if ($errno == E_NOTICE || $errno == E_STRICT) {
103   - if (PHPUnit_Framework_Notice::$enabled !== TRUE) {
  103 + if (PHPUnit_Framework_Error_Notice::$enabled !== TRUE) {
104 104 return FALSE;
105 105 }
106 106
107   - $exception = 'PHPUnit_Framework_Notice';
108   - } else {
  107 + $exception = 'PHPUnit_Framework_Error_Notice';
  108 + }
  109 +
  110 + else if ($errno == E_WARNING) {
  111 + if (PHPUnit_Framework_Error_Warning::$enabled !== TRUE) {
  112 + return FALSE;
  113 + }
  114 +
  115 + $exception = 'PHPUnit_Framework_Error_Warning';
  116 + }
  117 +
  118 + else {
109 119 $exception = 'PHPUnit_Framework_Error';
110 120 }
111 121
11 package.xml
@@ -383,6 +383,14 @@
383 383 <tasks:replace from="@package_version@" to="version" type="package-info" />
384 384 </file>
385 385 </dir>
  386 + <dir name="Error">
  387 + <file baseinstalldir="/" name="Notice.php" role="php">
  388 + <tasks:replace from="@package_version@" to="version" type="package-info" />
  389 + </file>
  390 + <file baseinstalldir="/" name="Warning.php" role="php">
  391 + <tasks:replace from="@package_version@" to="version" type="package-info" />
  392 + </file>
  393 + </dir>
386 394 <dir name="MockObject">
387 395 <dir name="Builder">
388 396 <file baseinstalldir="/" name="Identity.php" role="php">
@@ -508,9 +516,6 @@
508 516 <file baseinstalldir="/" name="IncompleteTest.php" role="php">
509 517 <tasks:replace from="@package_version@" to="version" type="package-info" />
510 518 </file>
511   - <file baseinstalldir="/" name="Notice.php" role="php">
512   - <tasks:replace from="@package_version@" to="version" type="package-info" />
513   - </file>
514 519 <file baseinstalldir="/" name="SelfDescribing.php" role="php">
515 520 <tasks:replace from="@package_version@" to="version" type="package-info" />
516 521 </file>

0 comments on commit 47a8833

Please sign in to comment.
Something went wrong with that request. Please try again.