Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ZipTask] fixed basedir #1255

Merged
merged 3 commits into from
Feb 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/phing/tasks/ext/ZipTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function main()

if (empty($this->filesets)) {
// add the main fileset to the list of filesets to process.
$mainFileSet = $this->fileset;
$mainFileSet = new ZipFileSet($this->fileset);
$mainFileSet->setDir($this->baseDir);
$this->filesets[] = $mainFileSet;
}
Expand Down
13 changes: 13 additions & 0 deletions test/classes/phing/tasks/ext/ZipUnzipTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ public function testZipFileSet()
$this->assertEquals('test.txt', $archive->getNameIndex(0));
}

public function testZipBaseDir()
{
$filename = PHING_TEST_BASE . '/etc/tasks/ext/tmp/simple-test.zip';

$this->executeTarget(__FUNCTION__);
$this->assertFileExists($filename);

$archive = new ZipArchive();
$archive->open($filename);

$this->assertEquals('test.txt', $archive->getNameIndex(0));
}

public function testUnzipSimpleZip()
{
$filename = PHING_TEST_BASE .
Expand Down
9 changes: 7 additions & 2 deletions test/etc/tasks/ext/ZipUnzipTaskTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@
</zipfileset>
</zip>
</target>


<target name="testZipBaseDir">
<echo file="${tmp.dir}/test.txt" message="TEST"/>
<zip destfile="${tmp.dir}/simple-test.zip" basedir="${tmp.dir}"/>
</target>

<target name="testUnzipSimpleZip" depends="testSimpleZipContainsOneFile">
<delete file="${tmp.dir}/test.txt"/>
<unzip file="${tmp.dir}/simple-test.zip" todir="${tmp.dir}"/>
</target>

<target name="main"/>
</project>
</project>