Skip to content

Commit

Permalink
fix: Add type to $excl parameter to fix type error
Browse files Browse the repository at this point in the history
This should fix phingofficial#1890
  • Loading branch information
jawira committed Jan 5, 2025
1 parent 7aa6d4a commit f3c14db
Show file tree
Hide file tree
Showing 5 changed files with 121 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");
}
}
101 changes: 101 additions & 0 deletions tests/etc/tasks/system/CopyTask/CopyTaskTest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="CopyTaskTest" default="main">
<property name="tmp.dir" value="tmp"/>

<fileset dir="vendor" id="vendor">
<include name="*"/>
</fileset>

<target name="setup">
<mkdir dir="${tmp.dir}"/>
</target>

<target name="clean">
<delete dir="${tmp.dir}"/>
</target>

<target name="testCopyDanglingSymlink">
<mkdir dir="${tmp.dir}/base"/>
<symlink target="${tmp.dir}/base/all" link="${tmp.dir}/base/dangling_symlink"/>

<copy todir="${tmp.dir}/new">
<fileset dir="${tmp.dir}/base">
<include name="*"/>
</fileset>
</copy>

<delete dir="${tmp.dir}/base"/>
<delete dir="${tmp.dir}/new"/>
</target>

<target name="testCopySymlinkPreserveLastModifiedShouldCopyTarget">
<mkdir dir="${tmp.dir}/base"/>
<mkdir dir="${tmp.dir}/new"/>
<echo file="${tmp.dir}/base/x" message="Testmessage"/>
<symlink target="x" link="${tmp.dir}/base/y"/>

<copy todir="${tmp.dir}/new" preserveLastModified="true">
<filelist dir="${tmp.dir}/base" files="y,x"/>
</copy>

<filesize file="${tmp.dir}/new/x" propertyname="test.filesize"/>

<delete dir="${tmp.dir}/base"/>
<delete dir="${tmp.dir}/new"/>
</target>

<target name="testCopyFileList">
<touch file="${tmp.dir}/Test1"/>
<touch file="${tmp.dir}/Test2"/>
<mkdir dir="copies"/>
<copy todir="copies">
<filelist dir="${tmp.dir}" files="Test1,Test2"/>
</copy>
<delete dir="copies"/>
</target>

<target name="testCopyDirSet">
<mkdir dir="${tmp.dir}/Test1"/>
<mkdir dir="${tmp.dir}/Test2"/>
<touch file="${tmp.dir}/Test1/a"/>
<touch file="${tmp.dir}/Test2/b"/>
<mkdir dir="copies"/>
<copy todir="copies" verbose="true">
<dirset dir="${tmp.dir}">
<include name="Test*"/>
</dirset>
</copy>
<delete dir="copies"/>
</target>

<target name="testOverwriteExistingSymlink">
<symlink target="${tmp.dir}/target-a" link="${tmp.dir}/link-a"/>
<symlink target="${tmp.dir}/target-b" link="${tmp.dir}/link-b"/>
<copy file="${tmp.dir}/link-a" tofile="${tmp.dir}/link-b" overwrite="true"/>
</target>

<target name="testGranularity" description="do not overwrite existing file without touching it first">
<touch mkdirs="true" file="${tmp.dir}/copysrcs/Test" datetime="-1 day"/>
<touch mkdirs="true" file="${tmp.dir}/copydest/Test" datetime="-1 year"/>
<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 f3c14db

Please sign in to comment.