Version 1
[yaffs-website] / vendor / phpunit / phpunit / src / Extensions / PhptTestSuite.php
1 <?php
2 /*
3  * This file is part of PHPUnit.
4  *
5  * (c) Sebastian Bergmann <sebastian@phpunit.de>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * Suite for .phpt test cases.
13  *
14  * @since Class available since Release 3.1.4
15  */
16 class PHPUnit_Extensions_PhptTestSuite extends PHPUnit_Framework_TestSuite
17 {
18     /**
19      * Constructs a new TestSuite for .phpt test cases.
20      *
21      * @param string $directory
22      *
23      * @throws PHPUnit_Framework_Exception
24      */
25     public function __construct($directory)
26     {
27         if (is_string($directory) && is_dir($directory)) {
28             $this->setName($directory);
29
30             $facade = new File_Iterator_Facade;
31             $files  = $facade->getFilesAsArray($directory, '.phpt');
32
33             foreach ($files as $file) {
34                 $this->addTestFile($file);
35             }
36         } else {
37             throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'directory name');
38         }
39     }
40 }