Permalink
Browse files

- Implemented #21271399: Deprecate the --phpunit-xml log option

  • Loading branch information...
1 parent 6503233 commit 658c25c19d91a7f82686bf972247deb561310c06 @manuelpichler manuelpichler committed Nov 22, 2011
@@ -47,6 +47,8 @@
* @deprecated Since release 0.10.5, please use the summary logger
*/
+// @codeCoverageIgnoreStart
+
/**
* This logger provides a xml log file, that is compatible with the files
* generated by the <a href="http://www.Phpunit.de">PHPUnit</a> --log-metrics
@@ -210,6 +212,11 @@ public function log(PHP_Depend_Metrics_AnalyzerI $analyzer)
*/
public function close()
{
+ trigger_error(
+ 'The --phpunit-xml log option is deprecated.',
+ E_USER_DEPRECATED
+ );
+
if ($this->_logFile === null) {
throw new PHP_Depend_Log_NoLogOutputException($this);
}
@@ -442,4 +449,6 @@ private function _applyPHPUnitTranslationTable(array $metrics)
}
return $metrics;
}
-}
+}
+
+// @codeCoverageIgnoreEnd
@@ -620,6 +620,11 @@ protected function collectAnalyzerOptions()
*/
private function _printOption($option, $message, $length)
{
+ // Ignore the phpunit xml option
+ if (0 === strpos($option, '--phpunit-xml=')) {
+ return;
+ }
+
// Calculate the max message length
$mlength = 77 - $length;
@@ -50,7 +50,6 @@
require_once dirname(__FILE__) . '/Jdepend/ChartTest.php';
require_once dirname(__FILE__) . '/Jdepend/XmlTest.php';
require_once dirname(__FILE__) . '/Overview/PyramidTest.php';
-require_once dirname(__FILE__) . '/Phpunit/XmlTest.php';
require_once dirname(__FILE__) . '/Summary/XmlTest.php';
/**
@@ -79,9 +78,8 @@ public static function suite()
$suite->addTestSuite('PHP_Depend_Log_Jdepend_ChartTest');
$suite->addTestSuite('PHP_Depend_Log_Jdepend_XmlTest');
$suite->addTestSuite('PHP_Depend_Log_Overview_PyramidTest');
- $suite->addTestSuite('PHP_Depend_Log_Phpunit_XmlTest');
$suite->addTestSuite('PHP_Depend_Log_Summary_XmlTest');
return $suite;
}
-}
+}
@@ -1,228 +0,0 @@
-<?php
-/**
- * This file is part of PHP_Depend.
- *
- * PHP Version 5
- *
- * Copyright (c) 2008-2011, Manuel Pichler <mapi@pdepend.org>.
- * 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 Manuel Pichler 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 QualityAssurance
- * @package PHP_Depend
- * @subpackage Log
- * @author Manuel Pichler <mapi@pdepend.org>
- * @copyright 2008-2011 Manuel Pichler. All rights reserved.
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version SVN: $Id$
- * @link http://pdepend.org/
- */
-
-require_once dirname(__FILE__) . '/../../AbstractTest.php';
-
-/**
- * Test case for the Phpunit logger.
- *
- * @category QualityAssurance
- * @package PHP_Depend
- * @subpackage Log
- * @author Manuel Pichler <mapi@pdepend.org>
- * @copyright 2008-2011 Manuel Pichler. All rights reserved.
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version Release: @package_version@
- * @link http://pdepend.org/
- *
- * @covers PHP_Depend_Log_Phpunit_Xml
- * @group pdepend
- * @group pdepend::logs
- * @group pdepend::logs::summary
- * @group unittest
- */
-class PHP_Depend_Log_Phpunit_XmlTest extends PHP_Depend_AbstractTest
-{
- /**
- * The temp log file.
- *
- * @var string $_tempFile
- */
- private $_tempFile = null;
-
- /**
- * Creates the temp log file name.
- *
- * @return void
- */
- protected function setUp()
- {
- parent::setUp();
-
- $this->_tempFile = self::createRunResourceURI('pdepend.phpunit-log.xml');
- if (file_exists($this->_tempFile)) {
- unlink($this->_tempFile);
- }
- }
-
- /**
- * Removes the temp log file
- *
- */
- protected function tearDown()
- {
- if (file_exists($this->_tempFile)) {
- unlink($this->_tempFile);
- }
-
- parent::tearDown();
- }
-
- /**
- * Tests that the logger returns the expected set of analyzers.
- *
- * @return void
- */
- public function testReturnsExceptedAnalyzers()
- {
- $logger = new PHP_Depend_Log_Phpunit_Xml(__FILE__);
- $actual = $logger->getAcceptedAnalyzers();
- $exptected = array(
- 'PHP_Depend_Metrics_NodeAwareI',
- 'PHP_Depend_Metrics_ProjectAwareI'
- );
-
- $this->assertEquals($exptected, $actual);
- }
-
- /**
- * Tests that the logger throws an exception if the log target wasn't
- * configured.
- *
- * @return void
- */
- public function testThrowsExceptionForInvalidLogTarget()
- {
- $this->setExpectedException(
- 'PHP_Depend_Log_NoLogOutputException',
- "The log target is not configured for 'PHP_Depend_Log_Phpunit_Xml'."
- );
-
- $logger = new PHP_Depend_Log_Phpunit_Xml();
- $logger->close();
- }
-
- /**
- * Tests the result of the Phpunit logger with some real analyzers.
- *
- * @return void
- */
- public function testPHPUnitLoggerResult()
- {
- $packages = self::parseCodeResourceForTest();
-
- $logger = new PHP_Depend_Log_Phpunit_Xml();
- $logger->setLogFile($this->_tempFile);
- $logger->setCode($packages);
-
- $analyzer0 = new PHP_Depend_Metrics_CyclomaticComplexity_Analyzer();
- $analyzer0->analyze($packages);
-
- $analyzer1 = new PHP_Depend_Metrics_ClassLevel_Analyzer();
- $analyzer1->addAnalyzer($analyzer0);
- $analyzer1->analyze($packages);
-
- $analyzer2 = new PHP_Depend_Metrics_CodeRank_Analyzer();
- $analyzer2->analyze($packages);
-
- $analyzer3 = new PHP_Depend_Metrics_Coupling_Analyzer();
- $analyzer3->analyze($packages);
-
- $analyzer4 = new PHP_Depend_Metrics_Hierarchy_Analyzer();
- $analyzer4->analyze($packages);
-
- $analyzer5 = new PHP_Depend_Metrics_Inheritance_Analyzer();
- $analyzer5->analyze($packages);
-
- $analyzer6 = new PHP_Depend_Metrics_NodeCount_Analyzer();
- $analyzer6->analyze($packages);
-
- $analyzer7 = new PHP_Depend_Metrics_NodeLoc_Analyzer();
- $analyzer7->analyze($packages);
-
- $logger->log($analyzer0);
- $logger->log($analyzer1);
- $logger->log($analyzer2);
- $logger->log($analyzer3);
- $logger->log($analyzer4);
- $logger->log($analyzer5);
- $logger->log($analyzer6);
- $logger->log($analyzer7);
-
- $logger->close();
-
- $actual = file_get_contents($this->_tempFile);
- $expected = $this->_loadExpected('phpunit-log.xml');
-
- $this->assertXmlStringEqualsXmlString($expected, $actual);
- }
-
- /**
- * testPHPUnitLogNotContainsNotUserDefinedClasses
- *
- * @return void
- */
- public function testPHPUnitLogNotContainsNotUserDefinedClasses()
- {
- $logger = new PHP_Depend_Log_Phpunit_Xml();
- $logger->setLogFile($this->_tempFile);
- $logger->setCode(self::parseCodeResourceForTest());
- $logger->close();
-
- $sxml = simplexml_load_file($this->_tempFile);
- $this->assertEquals(array(), $sxml->xpath('//class[@name="' . __FUNCTION__ . 'Parent"]'));
- }
-
- /**
- * Loads the expected log file and adjusts the file@name attribute.
- *
- * @param string $file The log file name.
- *
- * @return string
- */
- private function _loadExpected($file)
- {
- $path = self::createCodeResourceUriForTest();
-
- return preg_replace(
- '(file name="[^"]+/([^/"]+)")',
- 'file name="' . $path . '/\\1"',
- file_get_contents(dirname(__FILE__) . "/_expected/{$file}")
- );
- }
-}
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<metrics ahh="0" andc="0" calls="30" ccn="21" classes="3" cloc="217" clsa="0" clsc="3" fanout="29" files="4" functions="2" interfs="2" leafs="3" lloc="57" loc="336" locExecutable="101" maxdit="0" ncloc="119" nom="6" nop="1" roots="0">
- <file name="/home/manu/Desktop/Projects/workspace.xplib.de/PHP_Depend/trunk/tests/PHP/Depend/_code/log/phpunit/testPHPUnitLoggerResult/class.php" classes="2" cloc="84" functions="0" lloc="21" loc="128" locExecutable="36" ncloc="44">
- <class name="MyCouplingClass" ca="0" cbo="8" ce="8" cis="3" cloc="46" cr="0.15" csz="6" dit="0" impl="0" lloc="13" loc="82" locExecutable="22" ncloc="36" noam="0" nocc="0" nom="2" noom="0" npm="2" rcr="0.15" vars="4" varsi="4" varsnp="1" wmc="7" wmci="7" wmcnp="7">
- <method name="removeItemAt" ccn="3" cloc="0" lloc="5" loc="10" locExecutable="9" ncloc="10"/>
- <method name="getItemAt" ccn="4" cloc="0" lloc="8" loc="14" locExecutable="13" ncloc="14"/>
- </class>
- <class name="MyCouplingInterface" ca="2" cbo="2" ce="2" cloc="13" cr="0.15" lloc="0" loc="17" locExecutable="0" ncloc="4" nom="1" rcr="0.15">
- <method name="removeItemAt" cloc="0" lloc="0" loc="1" locExecutable="0" ncloc="1"/>
- </class>
- </file>
- <file name="/home/manu/Desktop/Projects/workspace.xplib.de/PHP_Depend/trunk/tests/PHP/Depend/_code/log/phpunit/testPHPUnitLoggerResult/method.php" classes="2" cloc="64" functions="0" lloc="17" loc="100" locExecutable="32" ncloc="36">
- <class name="MyMethodCouplingClass" ca="0" cbo="6" ce="6" cis="2" cloc="26" cr="0.15" csz="2" dit="0" impl="0" lloc="13" loc="54" locExecutable="22" ncloc="28" noam="0" nocc="0" nom="2" noom="0" npm="2" rcr="0.15" vars="0" varsi="0" varsnp="0" wmc="7" wmci="7" wmcnp="7">
- <method name="getItemAt" ccn="4" cloc="0" lloc="8" loc="14" locExecutable="13" ncloc="14"/>
- <method name="removeItemAt" ccn="3" cloc="0" lloc="5" loc="10" locExecutable="9" ncloc="10"/>
- </class>
- <class name="MyMethodCouplingInterface" ca="1" cbo="2" ce="2" cloc="13" cr="0.15" lloc="0" loc="17" locExecutable="0" ncloc="4" nom="1" rcr="0.15">
- <method name="removeItemAt" cloc="0" lloc="0" loc="1" locExecutable="0" ncloc="1"/>
- </class>
- </file>
- <file name="/home/manu/Desktop/Projects/workspace.xplib.de/PHP_Depend/trunk/tests/PHP/Depend/_code/log/phpunit/testPHPUnitLoggerResult/property.php" classes="1" cloc="36" functions="0" lloc="4" loc="48" locExecutable="8" ncloc="12">
- <class name="MyPropertyCouplingClass" ca="0" cbo="3" ce="3" cis="1" cloc="20" cr="0.15" csz="4" dit="0" impl="0" lloc="0" loc="30" locExecutable="0" ncloc="10" noam="0" nocc="0" nom="0" noom="0" npm="0" rcr="0.15" vars="4" varsi="4" varsnp="1" wmc="0" wmci="0" wmcnp="0"/>
- </file>
- <file name="/home/manu/Desktop/Projects/workspace.xplib.de/PHP_Depend/trunk/tests/PHP/Depend/_code/log/phpunit/testPHPUnitLoggerResult/function.php" classes="0" cloc="33" functions="2" lloc="15" loc="60" locExecutable="25" ncloc="27">
- <function name="getItemAt" ccn="4" cloc="0" lloc="8" loc="14" locExecutable="13" ncloc="14"/>
- <function name="removeItemAt" ccn="3" cloc="0" lloc="5" loc="10" locExecutable="9" ncloc="10"/>
- </file>
-</metrics>
@@ -1,5 +0,0 @@
-<?php
-class testPHPUnitLogNotContainsNotUserDefinedClasses extends testPHPUnitLogNotContainsNotUserDefinedClassesParent
-{
-
-}
Oops, something went wrong.

0 comments on commit 658c25c

Please sign in to comment.