Skip to content

Commit

Permalink
Fix fileset excludefile (#1892)
Browse files Browse the repository at this point in the history
* ComposerTask: update code & doc #1163

* fix: Add type to $excl parameter to fix type error

This fixes #1890

---------

Co-authored-by: Siad Ardroumli <[email protected]>
  • Loading branch information
jawira and siad007 authored Jan 15, 2025
1 parent 579928d commit e731640
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Phing/Type/AbstractFileSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public function setIncludesfile(File $incl)
*
* @throws BuildException
*/
public function setExcludesfile($excl)
public function setExcludesfile(File $excl)
{
if ($this->isReference()) {
throw $this->tooManyAttributes();
Expand Down
19 changes: 17 additions & 2 deletions tests/Phing/Test/Task/System/CopyTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function setUp(): void
{
$this->configureProject(
PHING_TEST_BASE
. '/etc/tasks/system/CopyTaskTest.xml'
. '/etc/tasks/system/CopyTask/CopyTaskTest.xml'
);
$this->executeTarget('setup');
}
Expand Down Expand Up @@ -90,11 +90,26 @@ public function testOverwriteExistingSymlink(): void
{
$this->executeTarget(__FUNCTION__);
$this->assertInLogs('Copying 1 file to');
$this->assertEquals('tmp/target-a', readlink(PHING_TEST_BASE . '/etc/tasks/system/tmp/link-b'));
$this->assertEquals('tmp/target-a', readlink(PHING_TEST_BASE . '/etc/tasks/system/CopyTask/tmp/link-b'));
}

public function testGranularity(): void
{
$this->expectLogContaining(__FUNCTION__, 'Test omitted, Test is up to date');
}

public function testFilesetFiles(): void
{
$destinationDir = PHING_TEST_BASE . '/etc/tasks/system/CopyTask/tmp/destination';
$this->assertDirectoryDoesNotExist($destinationDir);
$this->executeTarget(__FUNCTION__);
$this->assertFileExists("$destinationDir/Foo/Foo.php");
$this->assertFileExists("$destinationDir/Bar/Bar.php");
$this->assertFileExists("$destinationDir/Baz/Baz.php");
$this->assertFileExists("$destinationDir/Qux/Qux.php");
$this->assertFileDoesNotExist("$destinationDir/Foo/FooTest.php");
$this->assertFileDoesNotExist("$destinationDir/Bar/BarTest.php");
$this->assertFileDoesNotExist("$destinationDir/Baz/BazTest.php");
$this->assertFileDoesNotExist("$destinationDir/Qux/QuxTest.php");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,22 @@
<copy file="${tmp.dir}/copysrcs/Test" todir="${tmp.dir}/copydest" granularity="999999999" overwrite="false"/>
</target>

<target name="testFilesetFiles" description="test fileset include and excludes files">
<touch mkdirs="true" file="${tmp.dir}/source/Foo/Foo.php"/>
<touch mkdirs="true" file="${tmp.dir}/source/Foo/FooTest.php"/>
<touch mkdirs="true" file="${tmp.dir}/source/Bar/Bar.php"/>
<touch mkdirs="true" file="${tmp.dir}/source/Bar/BarTest.php"/>
<touch mkdirs="true" file="${tmp.dir}/source/Baz/Baz.php"/>
<touch mkdirs="true" file="${tmp.dir}/source/Baz/BazTest.php"/>
<touch mkdirs="true" file="${tmp.dir}/source/Qux/Qux.php"/>
<touch mkdirs="true" file="${tmp.dir}/source/Qux/QuxTest.php"/>
<mkdir dir="${tmp.dir}/destination"/>
<copy haltonerror="true" todir="${tmp.dir}/destination">
<fileset dir="${tmp.dir}/source"
includesfile="includes.txt"
excludesfile="excludes.txt"/>
</copy>
</target>

<target name="main"/>
</project>
1 change: 1 addition & 0 deletions tests/etc/tasks/system/CopyTask/excludes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*Test.php
1 change: 1 addition & 0 deletions tests/etc/tasks/system/CopyTask/includes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.php

0 comments on commit e731640

Please sign in to comment.