1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
5
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
6
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
7
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
8
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
9
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
10
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
11
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
12
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
13
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
14
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
15
|
|
|
* |
16
|
|
|
* This software consists of voluntary contributions made by many individuals |
17
|
|
|
* and is licensed under the LGPL. For more information please see |
18
|
|
|
* <http://phing.info>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace Phing\Test\Type; |
22
|
|
|
|
23
|
|
|
use Phing\Project; |
24
|
|
|
use Phing\Type\DirSet; |
25
|
|
|
use PHPUnit\Framework\TestCase; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Unit tests for DirSet -- including Selectors. |
29
|
|
|
* |
30
|
|
|
* @author Siad Ardroumli <[email protected]> |
31
|
|
|
* |
32
|
|
|
* @internal |
33
|
|
|
*/ |
34
|
|
|
class DirSetTest extends TestCase |
35
|
|
|
{ |
36
|
|
|
/** @var DirSet */ |
37
|
|
|
private $dirset; |
38
|
|
|
|
39
|
|
|
protected function setUp(): void |
40
|
|
|
{ |
41
|
|
|
$this->dirset = new DirSet(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testDirSetIterator(): void |
45
|
|
|
{ |
46
|
|
|
$this->dirset->setProject(new Project()); |
47
|
|
|
$this->dirset->setDir(__DIR__); |
48
|
|
|
$this->assertInstanceOf('ArrayIterator', $this->dirset->getIterator()); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function testOnlyDirs(): void |
52
|
|
|
{ |
53
|
|
|
$this->dirset->setProject(new Project()); |
54
|
|
|
$this->dirset->setDir(PHING_TEST_BASE); |
55
|
|
|
|
56
|
|
|
$ds = $this->dirset->getDirectoryScanner($this->dirset->getProject()); |
57
|
|
|
$expectedDirs = $ds->getIncludedDirectories(); |
58
|
|
|
|
59
|
|
|
$this->assertNotNull($expectedDirs, "There were no directories found."); |
60
|
|
|
$this->assertNotEmpty($expectedDirs, "There were no directories found."); |
61
|
|
|
foreach ($expectedDirs as $expectedDir) { |
62
|
|
|
$absPath = realpath($expectedDir); |
63
|
|
|
$this->assertNotFalse($absPath, "Unable to determine realpath for $expectedDir"); |
64
|
|
|
$this->assertTrue(is_dir($absPath), "$absPath was not a directory."); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
$expectedDirStr = implode(';', $expectedDirs); |
68
|
|
|
$acutalDirStr = $this->dirset . ""; |
69
|
|
|
$this->assertEquals($expectedDirStr, $acutalDirStr, "DirSet should only use directories."); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|