cvs: pear /PHP_CodeSniffer/tests AllTests.php /PHP_CodeSniffer/tests/Core AllTests.php IsCamelCapsTest.php /PHP_CodeSniffer/tests/Standards
AbstractSniffUnitTest.php AllSniffs.php
| From: | Greg Sherwood | Date: | Fri, 29 Dec 2006 00:05:45 +0000 |
| Subject: | cvs: pear /PHP_CodeSniffer/tests AllTests.php /PHP_CodeSniffer/tests/Core AllTests.php IsCamelCapsTest.php /PHP_CodeSniffer/tests/Standards AbstractSniffUnitTest.php AllSniffs.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-43869@lists.php.net to get a copy of this message | ||
squiz Fri Dec 29 00:05:45 2006 UTC
Modified files:
/pear/PHP_CodeSniffer/tests AllTests.php
/pear/PHP_CodeSniffer/tests/Core AllTests.php IsCamelCapsTest.php
/pear/PHP_CodeSniffer/tests/Standards AbstractSniffUnitTest.php
AllSniffs.php
Log:
Changed unit tests to work with PHPUnit 3
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/AllTests.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHP_CodeSniffer/tests/AllTests.php diff -u pear/PHP_CodeSniffer/tests/AllTests.php:1.2 pear/PHP_CodeSniffer/tests/AllTests.php:1.3 --- pear/PHP_CodeSniffer/tests/AllTests.php:1.2 Tue Dec 12 00:06:58 2006 +++ pear/PHP_CodeSniffer/tests/AllTests.php Fri Dec 29 00:05:44 2006 @@ -10,15 +10,16 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: AllTests.php,v 1.2 2006/12/12 00:06:58 squiz Exp $ + * @version CVS: $Id: AllTests.php,v 1.3 2006/12/29 00:05:44 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ -require_once 'PHPUnit2/Framework/TestSuite.php'; -require_once 'PHPUnit2/TextUI/TestRunner.php'; - +require_once 'PHPUnit/Framework/TestSuite.php'; +require_once 'PHPUnit/TextUI/TestRunner.php'; require_once 'CodeSniffer/Core/AllTests.php'; require_once 'CodeSniffer/Standards/AllSniffs.php'; +set_time_limit(0); +ini_set('memory_limit', '32M'); /** * A test class for running all PHP_CodeSniffer unit tests. @@ -45,7 +46,7 @@ */ public static function main() { - PHPUnit2_TextUI_TestRunner::run(self::suite()); + PHPUnit_TextUI_TestRunner::run(self::suite()); }//end main() @@ -53,11 +54,11 @@ /** * Add all PHP_CodeSniffer test suites into a single test suite. * - * @return PHPUnit2_Framework_TestSuite + * @return PHPUnit_Framework_TestSuite */ public static function suite() { - $suite = new PHPUnit2_Framework_TestSuite('PHP CodeSniffer'); + $suite = new PHPUnit_Framework_TestSuite('PHP CodeSniffer'); $suite->addTest(Core_AllTests::suite()); $suite->addTest(AllSniffs::suite()); http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Core/AllTests.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHP_CodeSniffer/tests/Core/AllTests.php diff -u pear/PHP_CodeSniffer/tests/Core/AllTests.php:1.2 pear/PHP_CodeSniffer/tests/Core/AllTests.php:1.3 --- pear/PHP_CodeSniffer/tests/Core/AllTests.php:1.2 Tue Dec 12 00:06:58 2006 +++ pear/PHP_CodeSniffer/tests/Core/AllTests.php Fri Dec 29 00:05:45 2006 @@ -10,13 +10,13 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: AllTests.php,v 1.2 2006/12/12 00:06:58 squiz Exp $ + * @version CVS: $Id: AllTests.php,v 1.3 2006/12/29 00:05:45 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ -require_once 'PHPUnit2/Framework/TestSuite.php'; -require_once 'PHPUnit2/TextUI/TestRunner.php'; -require_once 'PHPUnit2/Util/Filter.php'; +require_once 'PHPUnit/Framework/TestSuite.php'; +require_once 'PHPUnit/TextUI/TestRunner.php'; +require_once 'PHPUnit/Util/Filter.php'; require_once 'IsCamelCapsTest.php'; @@ -54,11 +54,11 @@ /** * Add all core unit tests into a test suite. * - * @return PHPUnit2_Framework_TestSuite + * @return PHPUnit_Framework_TestSuite */ public static function suite() { - $suite = new PHPUnit2_Framework_TestSuite('PHP CodeSniffer Core'); + $suite = new PHPUnit_Framework_TestSuite('PHP CodeSniffer Core'); $suite->addTestSuite('Core_IsCamelCapsTest'); return $suite; http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Core/IsCamelCapsTest.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHP_CodeSniffer/tests/Core/IsCamelCapsTest.php diff -u pear/PHP_CodeSniffer/tests/Core/IsCamelCapsTest.php:1.2 pear/PHP_CodeSniffer/tests/Core/IsCamelCapsTest.php:1.3 --- pear/PHP_CodeSniffer/tests/Core/IsCamelCapsTest.php:1.2 Tue Dec 12 00:06:58 2006 +++ pear/PHP_CodeSniffer/tests/Core/IsCamelCapsTest.php Fri Dec 29 00:05:45 2006 @@ -10,11 +10,11 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: IsCamelCapsTest.php,v 1.2 2006/12/12 00:06:58 squiz Exp $ + * @version CVS: $Id: IsCamelCapsTest.php,v 1.3 2006/12/29 00:05:45 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ -require_once 'PHPUnit2/Framework/TestCase.php'; +require_once 'PHPUnit/Framework/TestCase.php'; require_once 'PHP/CodeSniffer.php'; /** @@ -29,7 +29,7 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Core_IsCamelCapsTest extends PHPUnit2_Framework_TestCase +class Core_IsCamelCapsTest extends PHPUnit_Framework_TestCase { http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php?r1=1.3&r2=1.4&diff_format=u Index: pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php diff -u pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php:1.3 pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php:1.4 --- pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php:1.3 Wed Dec 27 03:35:23 2006 +++ pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php Fri Dec 29 00:05:45 2006 @@ -10,12 +10,12 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: AbstractSniffUnitTest.php,v 1.3 2006/12/27 03:35:23 squiz Exp $ + * @version CVS: $Id: AbstractSniffUnitTest.php,v 1.4 2006/12/29 00:05:45 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ require_once 'PHP/CodeSniffer.php'; -require_once 'PHPUnit2/Framework/TestCase.php'; +require_once 'PHPUnit/Framework/TestCase.php'; /** * An abstract class that all sniff unit tests must extend. @@ -33,7 +33,7 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/PHP_CodeSniffer */ -abstract class AbstractSniffUnitTest extends PHPUnit2_Framework_TestCase +abstract class AbstractSniffUnitTest extends PHPUnit_Framework_TestCase { /** @@ -62,8 +62,9 @@ * Tests the extending classes Sniff class. * * @return void + * @throws PHPUnit_Framework_Error */ - public final function testSniff() + protected final function runTest() { // The basis for determining file locations. $basename = substr(get_class($this), 0, -8); http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php diff -u pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php:1.2 pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php:1.3 --- pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php:1.2 Tue Dec 12 00:06:58 2006 +++ pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php Fri Dec 29 00:05:45 2006 @@ -10,13 +10,13 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: AllSniffs.php,v 1.2 2006/12/12 00:06:58 squiz Exp $ + * @version CVS: $Id: AllSniffs.php,v 1.3 2006/12/29 00:05:45 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ require_once 'PHP/CodeSniffer.php'; -require_once 'PHPUnit2/Framework/TestSuite.php'; -require_once 'PHPUnit2/TextUI/TestRunner.php'; +require_once 'PHPUnit/Framework/TestSuite.php'; +require_once 'PHPUnit/TextUI/TestRunner.php'; // Require this here so that the unit tests don't have to try and find the // abstract class once it is installed into the PEAR tests directory. @@ -50,7 +50,7 @@ */ public static function main() { - PHPUnit2_TextUI_TestRunner::run(self::suite()); + PHPUnit_TextUI_TestRunner::run(self::suite()); }//end main() @@ -61,11 +61,11 @@ * Sniff unit tests are found by recursing through the 'Tests' directory * of each installed coding standard. * - * @return PHPUnit2_Framework_TestSuite + * @return PHPUnit_Framework_TestSuite */ public static function suite() { - $suite = new PHPUnit2_Framework_TestSuite('PHP CodeSniffer Standards'); + $suite = new PHPUnit_Framework_TestSuite('PHP CodeSniffer Standards'); $standards = PHP_CodeSniffer::getInstalledStandards(true); foreach ($standards as $standard) { @@ -84,9 +84,11 @@ $className = str_replace(dirname(__FILE__).'/', '', $filePath); $className = substr($className, 0, -4); $className = str_replace('/', '_', $className); + $niceName = substr($className, (strrpos($className, '_') + 1), -8); include_once $file->getPathname(); - $suite->addTestSuite($className); + $class = new $className($niceName); + $suite->addTest($class); } }
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/AllTests.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHP_CodeSniffer/tests/AllTests.php diff -u pear/PHP_CodeSniffer/tests/AllTests.php:1.2 pear/PHP_CodeSniffer/tests/AllTests.php:1.3 --- pear/PHP_CodeSniffer/tests/AllTests.php:1.2 Tue Dec 12 00:06:58 2006 +++ pear/PHP_CodeSniffer/tests/AllTests.php Fri Dec 29 00:05:44 2006 @@ -10,15 +10,16 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: AllTests.php,v 1.2 2006/12/12 00:06:58 squiz Exp $ + * @version CVS: $Id: AllTests.php,v 1.3 2006/12/29 00:05:44 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ -require_once 'PHPUnit2/Framework/TestSuite.php'; -require_once 'PHPUnit2/TextUI/TestRunner.php'; - +require_once 'PHPUnit/Framework/TestSuite.php'; +require_once 'PHPUnit/TextUI/TestRunner.php'; require_once 'CodeSniffer/Core/AllTests.php'; require_once 'CodeSniffer/Standards/AllSniffs.php'; +set_time_limit(0); +ini_set('memory_limit', '32M'); /** * A test class for running all PHP_CodeSniffer unit tests. @@ -45,7 +46,7 @@ */ public static function main() { - PHPUnit2_TextUI_TestRunner::run(self::suite()); + PHPUnit_TextUI_TestRunner::run(self::suite()); }//end main() @@ -53,11 +54,11 @@ /** * Add all PHP_CodeSniffer test suites into a single test suite. * - * @return PHPUnit2_Framework_TestSuite + * @return PHPUnit_Framework_TestSuite */ public static function suite() { - $suite = new PHPUnit2_Framework_TestSuite('PHP CodeSniffer'); + $suite = new PHPUnit_Framework_TestSuite('PHP CodeSniffer'); $suite->addTest(Core_AllTests::suite()); $suite->addTest(AllSniffs::suite()); http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Core/AllTests.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHP_CodeSniffer/tests/Core/AllTests.php diff -u pear/PHP_CodeSniffer/tests/Core/AllTests.php:1.2 pear/PHP_CodeSniffer/tests/Core/AllTests.php:1.3 --- pear/PHP_CodeSniffer/tests/Core/AllTests.php:1.2 Tue Dec 12 00:06:58 2006 +++ pear/PHP_CodeSniffer/tests/Core/AllTests.php Fri Dec 29 00:05:45 2006 @@ -10,13 +10,13 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: AllTests.php,v 1.2 2006/12/12 00:06:58 squiz Exp $ + * @version CVS: $Id: AllTests.php,v 1.3 2006/12/29 00:05:45 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ -require_once 'PHPUnit2/Framework/TestSuite.php'; -require_once 'PHPUnit2/TextUI/TestRunner.php'; -require_once 'PHPUnit2/Util/Filter.php'; +require_once 'PHPUnit/Framework/TestSuite.php'; +require_once 'PHPUnit/TextUI/TestRunner.php'; +require_once 'PHPUnit/Util/Filter.php'; require_once 'IsCamelCapsTest.php'; @@ -54,11 +54,11 @@ /** * Add all core unit tests into a test suite. * - * @return PHPUnit2_Framework_TestSuite + * @return PHPUnit_Framework_TestSuite */ public static function suite() { - $suite = new PHPUnit2_Framework_TestSuite('PHP CodeSniffer Core'); + $suite = new PHPUnit_Framework_TestSuite('PHP CodeSniffer Core'); $suite->addTestSuite('Core_IsCamelCapsTest'); return $suite; http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Core/IsCamelCapsTest.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHP_CodeSniffer/tests/Core/IsCamelCapsTest.php diff -u pear/PHP_CodeSniffer/tests/Core/IsCamelCapsTest.php:1.2 pear/PHP_CodeSniffer/tests/Core/IsCamelCapsTest.php:1.3 --- pear/PHP_CodeSniffer/tests/Core/IsCamelCapsTest.php:1.2 Tue Dec 12 00:06:58 2006 +++ pear/PHP_CodeSniffer/tests/Core/IsCamelCapsTest.php Fri Dec 29 00:05:45 2006 @@ -10,11 +10,11 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: IsCamelCapsTest.php,v 1.2 2006/12/12 00:06:58 squiz Exp $ + * @version CVS: $Id: IsCamelCapsTest.php,v 1.3 2006/12/29 00:05:45 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ -require_once 'PHPUnit2/Framework/TestCase.php'; +require_once 'PHPUnit/Framework/TestCase.php'; require_once 'PHP/CodeSniffer.php'; /** @@ -29,7 +29,7 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Core_IsCamelCapsTest extends PHPUnit2_Framework_TestCase +class Core_IsCamelCapsTest extends PHPUnit_Framework_TestCase { http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php?r1=1.3&r2=1.4&diff_format=u Index: pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php diff -u pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php:1.3 pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php:1.4 --- pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php:1.3 Wed Dec 27 03:35:23 2006 +++ pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php Fri Dec 29 00:05:45 2006 @@ -10,12 +10,12 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: AbstractSniffUnitTest.php,v 1.3 2006/12/27 03:35:23 squiz Exp $ + * @version CVS: $Id: AbstractSniffUnitTest.php,v 1.4 2006/12/29 00:05:45 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ require_once 'PHP/CodeSniffer.php'; -require_once 'PHPUnit2/Framework/TestCase.php'; +require_once 'PHPUnit/Framework/TestCase.php'; /** * An abstract class that all sniff unit tests must extend. @@ -33,7 +33,7 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/PHP_CodeSniffer */ -abstract class AbstractSniffUnitTest extends PHPUnit2_Framework_TestCase +abstract class AbstractSniffUnitTest extends PHPUnit_Framework_TestCase { /** @@ -62,8 +62,9 @@ * Tests the extending classes Sniff class. * * @return void + * @throws PHPUnit_Framework_Error */ - public final function testSniff() + protected final function runTest() { // The basis for determining file locations. $basename = substr(get_class($this), 0, -8); http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php diff -u pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php:1.2 pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php:1.3 --- pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php:1.2 Tue Dec 12 00:06:58 2006 +++ pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php Fri Dec 29 00:05:45 2006 @@ -10,13 +10,13 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: AllSniffs.php,v 1.2 2006/12/12 00:06:58 squiz Exp $ + * @version CVS: $Id: AllSniffs.php,v 1.3 2006/12/29 00:05:45 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ require_once 'PHP/CodeSniffer.php'; -require_once 'PHPUnit2/Framework/TestSuite.php'; -require_once 'PHPUnit2/TextUI/TestRunner.php'; +require_once 'PHPUnit/Framework/TestSuite.php'; +require_once 'PHPUnit/TextUI/TestRunner.php'; // Require this here so that the unit tests don't have to try and find the // abstract class once it is installed into the PEAR tests directory. @@ -50,7 +50,7 @@ */ public static function main() { - PHPUnit2_TextUI_TestRunner::run(self::suite()); + PHPUnit_TextUI_TestRunner::run(self::suite()); }//end main() @@ -61,11 +61,11 @@ * Sniff unit tests are found by recursing through the 'Tests' directory * of each installed coding standard. * - * @return PHPUnit2_Framework_TestSuite + * @return PHPUnit_Framework_TestSuite */ public static function suite() { - $suite = new PHPUnit2_Framework_TestSuite('PHP CodeSniffer Standards'); + $suite = new PHPUnit_Framework_TestSuite('PHP CodeSniffer Standards'); $standards = PHP_CodeSniffer::getInstalledStandards(true); foreach ($standards as $standard) { @@ -84,9 +84,11 @@ $className = str_replace(dirname(__FILE__).'/', '', $filePath); $className = substr($className, 0, -4); $className = str_replace('/', '_', $className); + $niceName = substr($className, (strrpos($className, '_') + 1), -8); include_once $file->getPathname(); - $suite->addTestSuite($className); + $class = new $className($niceName); + $suite->addTest($class); } }