cvs: pear /PHP_CodeSniffer/tests AbstractSniffUnitTest.php AllSniffs.php /PHP_CodeSniffer/tests/Standards AbstractSniffUnitTest.php AllSniffs.php
| From: | Greg Sherwood | Date: | Fri, 06 Oct 2006 01:05:04 +0000 |
| Subject: | cvs: pear /PHP_CodeSniffer/tests AbstractSniffUnitTest.php AllSniffs.php /PHP_CodeSniffer/tests/Standards AbstractSniffUnitTest.php AllSniffs.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-42424@lists.php.net to get a copy of this message | ||
squiz Fri Oct 6 01:05:04 2006 UTC
Added files:
/pear/PHP_CodeSniffer/tests/Standards AbstractSniffUnitTest.php
AllSniffs.php
Removed files:
/pear/PHP_CodeSniffer/tests AllSniffs.php AbstractSniffUnitTest.php
Log:
Moving these test files into a Standards dir to separate them from the other tests
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php +++ pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php <?php /** * +------------------------------------------------------------------------+ * | BSD Licence | * +------------------------------------------------------------------------+ * | This software is available to you under the BSD license, | * | available in the LICENSE file accompanying this software. | * | You may obtain a copy of the License at | * | | * | http://matrix.squiz.net/developer/tools/php_cs/licence | * | | * | 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. | * +------------------------------------------------------------------------+ * | Copyright (c), 2006 Squiz Pty Ltd (ABN 77 084 670 600). | * | All rights reserved. | * +------------------------------------------------------------------------+ * * @package PHP_CodeSniffer * @category Testing * @author Squiz Pty Ltd */ require_once 'PHP/CodeSniffer.php'; require_once 'PHPUnit2/Framework/TestCase.php'; /** * An abstract class that all sniff unit tests must extend. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings that are not found, or * warnings and errors that are not expected, are considered test failures. * * @package PHP_CodeSniffer * @category Testing * @author Squiz Pty Ltd */ abstract class AbstractSniffUnitTest extends PHPUnit2_Framework_TestCase { /** * The PHP_CodeSniffer object used for testing. * * @var PHP_CodeSniffer */ protected static $phpcs = null; /** * Sets up this unit test. * * @return void */ protected function setUp() { if (self::$phpcs === null) { self::$phpcs = new PHP_CodeSniffer(); } }//end setUp() /** * Tests the extending classes Sniff class. * * @return void */ public final function testSniff() { // The basis for determining file locations. $basename = substr(get_class($this), 0, -8); // The name of the dummy file we are testing. $testFile = dirname(__FILE__).'/'.str_replace('_', '/', $basename).'UnitTest.inc'; // The name of the coding standard we are testing. $standardName = substr($basename, 0, strpos($basename, '_')); // The class name of the sniff we are testing. $sniffClass = str_replace('_Tests_', '_Sniffs_', $basename).'Sniff'; try { self::$phpcs->process($testFile, $standardName, array($sniffClass)); } catch (Exception $e) { $this->fail('An unexpected exception has been caught: '.$e->getMessage()); } $files = self::$phpcs->getFiles(); $file = array_pop($files); $foundErrors = $file->getErrors(); $foundWarnings = $file->getWarnings(); $expectedErrors = $this->getErrorList(); $expectedWarnings = $this->getWarningList(); if (is_array($expectedErrors) === false) { throw new Exception('getErrorList() must return an array'); } if (is_array($expectedWarnings) === false) { throw new Exception('getWarningList() must return an array'); } /* We merge errors and warnings together to make it easier to iterate over them and produce the errors string. In this way, we can report on errors and warnings in the same line even though it's not really structured to allow that. */ $allProblems = array(); foreach ($foundErrors as $line => $errors) { if (isset($allProblems[$line]) === false) { $allProblems[$line] = array( 'expected_errors' => 0, 'expected_warnings' => 0, 'found_errors' => array(), 'found_warnings' => array(), ); } $allProblems[$line]['found_errors'] = $errors; if (isset($expectedErrors[$line]) === true) { $allProblems[$line]['expected_errors'] = $expectedErrors[$line]; } else { $allProblems[$line]['expected_errors'] = 0; } unset($expectedErrors[$line]); } foreach ($expectedErrors as $line => $numErrors) { if (isset($allProblems[$line]) === false) { $allProblems[$line] = array( 'expected_errors' => 0, 'expected_warnings' => 0, 'found_errors' => array(), 'found_warnings' => array(), ); } $allProblems[$line]['expected_errors'] = $numErrors; } foreach ($foundWarnings as $line => $warnings) { if (isset($allProblems[$line]) === false) { $allProblems[$line] = array( 'expected_errors' => 0, 'expected_warnings' => 0, 'found_errors' => array(), 'found_warnings' => array(), ); } $allProblems[$line]['found_warnings'] = $warnings; if (isset($expectedWarnings[$line]) === true) { $allProblems[$line]['expected_warnings'] = $expectedWarnings[$line]; } else { $allProblems[$line]['expected_warnings'] = 0; } unset($expectedWarnings[$line]); } foreach ($expectedWarnings as $line => $numWarnings) { if (isset($allProblems[$line]) === false) { $allProblems[$line] = array( 'expected_errors' => 0, 'expected_warnings' => 0, 'found_errors' => array(), 'found_warnings' => array(), ); } $allProblems[$line]['expected_warnings'] = $numWarnings; } // Order the messages by line number. ksort($allProblems); $failureMessages = array(); foreach ($allProblems as $line => $problems) { $numErrors = count($problems['found_errors']); $numWarnings = count($problems['found_warnings']); $expectedErrors = $problems['expected_errors']; $expectedWarnings = $problems['expected_warnings']; $errors = ''; $foundString = ''; if ($expectedErrors !== $numErrors || $expectedWarnings !== $numWarnings) { $lineMessage = "[LINE $line]"; $expectedMessage = 'Expected '; $foundMessage = 'but found '; if ($expectedErrors !== $numErrors) { $expectedMessage .= "$expectedErrors error(s)"; $foundMessage .= "$numErrors error(s)"; if ($numErrors !== 0) { $foundString .= 'errors'; $errors .= implode("\n -> ", $problems['found_errors']); } if ($expectedWarnings !== $numWarnings) { $expectedMessage .= ' and '; $foundMessage .= ' and '; if ($numWarnings !== 0) { $foundString .= ' and '; } } } if ($expectedWarnings !== $numWarnings) { $expectedMessage .= "$expectedWarnings warning(s)"; $foundMessage .= "$numWarnings warning(s)"; if ($numWarnings !== 0) { $foundString .= 'warnings'; $errors .= implode("\n -> ", $problems['found_warnings']); } } $fullMessage = "$lineMessage $expectedMessage $foundMessage."; if ($errors !== '') { $fullMessage .= " The $foundString found were:\n -> $errors"; } $failureMessages[] = $fullMessage; } }//end foreach if (empty($failureMessages) === false) { $this->fail(implode("\n", $failureMessages)); } }//end testSniff() /** * Returns the lines where errors should occur. * * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * * @return array(int => int) */ protected abstract function getErrorList(); /** * Returns the lines where warnings should occur. * * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * * @return array(int => int) */ protected abstract function getWarningList(); }//end class ?> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php +++ pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php <?php /** * +------------------------------------------------------------------------+ * | BSD Licence | * +------------------------------------------------------------------------+ * | This software is available to you under the BSD license, | * | available in the LICENSE file accompanying this software. | * | You may obtain a copy of the License at | * | | * | http://matrix.squiz.net/developer/tools/php_cs/licence | * | | * | 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. | * +------------------------------------------------------------------------+ * | Copyright (c), 2006 Squiz Pty Ltd (ABN 77 084 670 600). | * | All rights reserved. | * +------------------------------------------------------------------------+ * * @package PHP_CodeSniffer * @category Testing * @author Squiz Pty Ltd */ require_once 'PHP/CodeSniffer.php'; require_once 'PHPUnit2/Framework/TestSuite.php'; require_once 'PHPUnit2/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. require_once dirname(__FILE__).'/AbstractSniffUnitTest.php'; /** * A test class for testing all sniffs for installed standards. * * Usage: phpunit AllSniffs.php * * This test class loads all unit tests for all installed standards into a * single test suite and runs them. Errors are reported on the command line. * * @package PHP_CodeSniffer * @category Testing * @author Squiz Pty Ltd */ class AllSniffs { /** * Prepare the test runner. * * @return void */ public static function main() { PHPUnit2_TextUI_TestRunner::run(self::suite()); }//end main() /** * Add all sniff unit tests into a test suite. * * Sniff unit tests are found by recursing through the 'Tests' directory * of each installed coding standard. * * @return PHPUnit2_Framework_TestSuite */ public static function suite() { $suite = new PHPUnit2_Framework_TestSuite('PHP CodeSniffer Standards'); $standards = PHP_CodeSniffer::getInstalledStandards(true); foreach ($standards as $standard) { $standardDir = dirname(__FILE__).'/'.$standard.'/Tests/'; $di = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($standardDir)); foreach ($di as $file) { // Tests must have the extention 'php'. $parts = explode('.', $file); $ext = array_pop($parts); if ($ext !== 'php') { continue; } $filePath = $file->getPathname(); $className = str_replace(dirname(__FILE__).'/', '', $filePath); $className = substr($className, 0, -4); $className = str_replace('/', '_', $className); include_once $file->getPathname(); $suite->addTestSuite($className); } } return $suite; }//end suite() }//end class ?>
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php +++ pear/PHP_CodeSniffer/tests/Standards/AbstractSniffUnitTest.php <?php /** * +------------------------------------------------------------------------+ * | BSD Licence | * +------------------------------------------------------------------------+ * | This software is available to you under the BSD license, | * | available in the LICENSE file accompanying this software. | * | You may obtain a copy of the License at | * | | * | http://matrix.squiz.net/developer/tools/php_cs/licence | * | | * | 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. | * +------------------------------------------------------------------------+ * | Copyright (c), 2006 Squiz Pty Ltd (ABN 77 084 670 600). | * | All rights reserved. | * +------------------------------------------------------------------------+ * * @package PHP_CodeSniffer * @category Testing * @author Squiz Pty Ltd */ require_once 'PHP/CodeSniffer.php'; require_once 'PHPUnit2/Framework/TestCase.php'; /** * An abstract class that all sniff unit tests must extend. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings that are not found, or * warnings and errors that are not expected, are considered test failures. * * @package PHP_CodeSniffer * @category Testing * @author Squiz Pty Ltd */ abstract class AbstractSniffUnitTest extends PHPUnit2_Framework_TestCase { /** * The PHP_CodeSniffer object used for testing. * * @var PHP_CodeSniffer */ protected static $phpcs = null; /** * Sets up this unit test. * * @return void */ protected function setUp() { if (self::$phpcs === null) { self::$phpcs = new PHP_CodeSniffer(); } }//end setUp() /** * Tests the extending classes Sniff class. * * @return void */ public final function testSniff() { // The basis for determining file locations. $basename = substr(get_class($this), 0, -8); // The name of the dummy file we are testing. $testFile = dirname(__FILE__).'/'.str_replace('_', '/', $basename).'UnitTest.inc'; // The name of the coding standard we are testing. $standardName = substr($basename, 0, strpos($basename, '_')); // The class name of the sniff we are testing. $sniffClass = str_replace('_Tests_', '_Sniffs_', $basename).'Sniff'; try { self::$phpcs->process($testFile, $standardName, array($sniffClass)); } catch (Exception $e) { $this->fail('An unexpected exception has been caught: '.$e->getMessage()); } $files = self::$phpcs->getFiles(); $file = array_pop($files); $foundErrors = $file->getErrors(); $foundWarnings = $file->getWarnings(); $expectedErrors = $this->getErrorList(); $expectedWarnings = $this->getWarningList(); if (is_array($expectedErrors) === false) { throw new Exception('getErrorList() must return an array'); } if (is_array($expectedWarnings) === false) { throw new Exception('getWarningList() must return an array'); } /* We merge errors and warnings together to make it easier to iterate over them and produce the errors string. In this way, we can report on errors and warnings in the same line even though it's not really structured to allow that. */ $allProblems = array(); foreach ($foundErrors as $line => $errors) { if (isset($allProblems[$line]) === false) { $allProblems[$line] = array( 'expected_errors' => 0, 'expected_warnings' => 0, 'found_errors' => array(), 'found_warnings' => array(), ); } $allProblems[$line]['found_errors'] = $errors; if (isset($expectedErrors[$line]) === true) { $allProblems[$line]['expected_errors'] = $expectedErrors[$line]; } else { $allProblems[$line]['expected_errors'] = 0; } unset($expectedErrors[$line]); } foreach ($expectedErrors as $line => $numErrors) { if (isset($allProblems[$line]) === false) { $allProblems[$line] = array( 'expected_errors' => 0, 'expected_warnings' => 0, 'found_errors' => array(), 'found_warnings' => array(), ); } $allProblems[$line]['expected_errors'] = $numErrors; } foreach ($foundWarnings as $line => $warnings) { if (isset($allProblems[$line]) === false) { $allProblems[$line] = array( 'expected_errors' => 0, 'expected_warnings' => 0, 'found_errors' => array(), 'found_warnings' => array(), ); } $allProblems[$line]['found_warnings'] = $warnings; if (isset($expectedWarnings[$line]) === true) { $allProblems[$line]['expected_warnings'] = $expectedWarnings[$line]; } else { $allProblems[$line]['expected_warnings'] = 0; } unset($expectedWarnings[$line]); } foreach ($expectedWarnings as $line => $numWarnings) { if (isset($allProblems[$line]) === false) { $allProblems[$line] = array( 'expected_errors' => 0, 'expected_warnings' => 0, 'found_errors' => array(), 'found_warnings' => array(), ); } $allProblems[$line]['expected_warnings'] = $numWarnings; } // Order the messages by line number. ksort($allProblems); $failureMessages = array(); foreach ($allProblems as $line => $problems) { $numErrors = count($problems['found_errors']); $numWarnings = count($problems['found_warnings']); $expectedErrors = $problems['expected_errors']; $expectedWarnings = $problems['expected_warnings']; $errors = ''; $foundString = ''; if ($expectedErrors !== $numErrors || $expectedWarnings !== $numWarnings) { $lineMessage = "[LINE $line]"; $expectedMessage = 'Expected '; $foundMessage = 'but found '; if ($expectedErrors !== $numErrors) { $expectedMessage .= "$expectedErrors error(s)"; $foundMessage .= "$numErrors error(s)"; if ($numErrors !== 0) { $foundString .= 'errors'; $errors .= implode("\n -> ", $problems['found_errors']); } if ($expectedWarnings !== $numWarnings) { $expectedMessage .= ' and '; $foundMessage .= ' and '; if ($numWarnings !== 0) { $foundString .= ' and '; } } } if ($expectedWarnings !== $numWarnings) { $expectedMessage .= "$expectedWarnings warning(s)"; $foundMessage .= "$numWarnings warning(s)"; if ($numWarnings !== 0) { $foundString .= 'warnings'; $errors .= implode("\n -> ", $problems['found_warnings']); } } $fullMessage = "$lineMessage $expectedMessage $foundMessage."; if ($errors !== '') { $fullMessage .= " The $foundString found were:\n -> $errors"; } $failureMessages[] = $fullMessage; } }//end foreach if (empty($failureMessages) === false) { $this->fail(implode("\n", $failureMessages)); } }//end testSniff() /** * Returns the lines where errors should occur. * * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * * @return array(int => int) */ protected abstract function getErrorList(); /** * Returns the lines where warnings should occur. * * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * * @return array(int => int) */ protected abstract function getWarningList(); }//end class ?> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php?view=markup&rev=1.1 Index: pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php +++ pear/PHP_CodeSniffer/tests/Standards/AllSniffs.php <?php /** * +------------------------------------------------------------------------+ * | BSD Licence | * +------------------------------------------------------------------------+ * | This software is available to you under the BSD license, | * | available in the LICENSE file accompanying this software. | * | You may obtain a copy of the License at | * | | * | http://matrix.squiz.net/developer/tools/php_cs/licence | * | | * | 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. | * +------------------------------------------------------------------------+ * | Copyright (c), 2006 Squiz Pty Ltd (ABN 77 084 670 600). | * | All rights reserved. | * +------------------------------------------------------------------------+ * * @package PHP_CodeSniffer * @category Testing * @author Squiz Pty Ltd */ require_once 'PHP/CodeSniffer.php'; require_once 'PHPUnit2/Framework/TestSuite.php'; require_once 'PHPUnit2/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. require_once dirname(__FILE__).'/AbstractSniffUnitTest.php'; /** * A test class for testing all sniffs for installed standards. * * Usage: phpunit AllSniffs.php * * This test class loads all unit tests for all installed standards into a * single test suite and runs them. Errors are reported on the command line. * * @package PHP_CodeSniffer * @category Testing * @author Squiz Pty Ltd */ class AllSniffs { /** * Prepare the test runner. * * @return void */ public static function main() { PHPUnit2_TextUI_TestRunner::run(self::suite()); }//end main() /** * Add all sniff unit tests into a test suite. * * Sniff unit tests are found by recursing through the 'Tests' directory * of each installed coding standard. * * @return PHPUnit2_Framework_TestSuite */ public static function suite() { $suite = new PHPUnit2_Framework_TestSuite('PHP CodeSniffer Standards'); $standards = PHP_CodeSniffer::getInstalledStandards(true); foreach ($standards as $standard) { $standardDir = dirname(__FILE__).'/'.$standard.'/Tests/'; $di = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($standardDir)); foreach ($di as $file) { // Tests must have the extention 'php'. $parts = explode('.', $file); $ext = array_pop($parts); if ($ext !== 'php') { continue; } $filePath = $file->getPathname(); $className = str_replace(dirname(__FILE__).'/', '', $filePath); $className = substr($className, 0, -4); $className = str_replace('/', '_', $className); include_once $file->getPathname(); $suite->addTestSuite($className); } } return $suite; }//end suite() }//end class ?>