Skip to content

Commit 69b1ad8

Browse files
committed
[TESTCASE] Check that patches can create new files (related to #1)
1 parent 8ee6108 commit 69b1ad8

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

tests/Functional/CoreFeatureTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class CoreFeatureTest extends SandboxTestCase
1616
]
1717
];
1818

19+
const PACKAGEA_NON_POSIX_PATCHSET_APPLICATIONS = [
20+
'/vendor/test/package-a/file-added-by-patch.md' => 'This file has been created by patch'
21+
];
22+
1923
const ROOT_PACKAGE_APPLICATIONS = [
2024
'/src/root-code.php' => '-is-patched'
2125
];
@@ -268,4 +272,19 @@ public function testGitApplyCanBeUsedForPatching()
268272
$this->assertContains('using git method', $installRun->getFullOutput(), 'patches were applied using git', true);
269273
$this->assertNotContains('using patch method', $installRun->getFullOutput(), 'no patches were applied using patch command', true);
270274
}
275+
276+
public function testPatchesCanCreateNewFiles()
277+
{
278+
$project = $this->getSandbox()->createProjectSandBox('test/project-template', 'dev-master', [
279+
'require' => [
280+
'test/patchset-non-posix'=> '~1.0',
281+
'test/package-a'=> 'dev-master',
282+
'creativestyle/composer-plugin-patchset'=> 'dev-master'
283+
]
284+
]);
285+
286+
$run = $project->runComposerCommand('install');
287+
288+
$this->assertThatComposerRunHasAppliedPatches($run, self::PACKAGEA_NON_POSIX_PATCHSET_APPLICATIONS);
289+
}
271290
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "test/patchset-non-posix",
3+
"type": "patchset",
4+
"version": "1.3",
5+
"description": "Tests non-posix compatible patches",
6+
"require": {
7+
"creativestyle/composer-plugin-patchset": "dev-master"
8+
},
9+
"extra": {
10+
"patchset": {
11+
"test/package-a": [
12+
{
13+
"description": "Create new file",
14+
"filename": "patches/new-file-patch.diff"
15+
}
16+
]
17+
}
18+
}
19+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
new file mode 100755
2+
--- /dev/null
3+
+++ b/file-added-by-patch.md
4+
@@ -0,0 +1,8 @@
5+
+# This file has been created by patch
6+
+
7+
+*The `--posix` switch for `--patch` command disables support
8+
+ for new file creation causing patch application failure.*
9+
+
10+
+ This feature is supported out-of-the-box with git patching
11+
+ and relatively widely used so should be supported.
12+
+
13+
14+

0 commit comments

Comments
 (0)