Skip to content

Commit 23ce11d

Browse files
committed
fix tests for windows... maybe?
1 parent 323c235 commit 23ce11d

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

tests/Feature/RunTest.php

+23-13
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@
1919
->with(Platform::cwd('.git/hooks/skip-once'))
2020
->andReturnTrue();
2121

22+
$tmp_file = Platform::temp_test_path('whisky_test_commit_msg');
23+
2224
File::shouldReceive('get')
2325
->with(Platform::cwd('whisky.json'))
24-
->andReturn(<<<'JSON'
26+
->andReturn(<<<"JSON"
2527
{
2628
"disabled": [],
2729
"hooks": {
2830
"pre-commit": [
29-
"echo \"poop\" > /tmp/whisky_test_commit_msg"
31+
"echo \"poop\" > {$tmp_file}"
3032
]
3133
}
3234
}
@@ -35,7 +37,7 @@
3537
$this->artisan('run pre-commit')
3638
->assertExitCode(0);
3739

38-
expect(file_exists('/tmp/whisky_test_commit_msg'))
40+
expect(file_exists($tmp_file))
3941
->toBeFalse();
4042
});
4143

@@ -48,19 +50,21 @@
4850
->with(Platform::cwd('.git/hooks/skip-once'))
4951
->andReturnFalse();
5052

53+
$tmp_file = Platform::temp_test_path('whisky_test_commit_msg');
54+
5155
/**
5256
* We need to send the output to the disk
5357
* otherwise the output is sent to the
5458
* test output and we can't check it.
5559
*/
5660
File::shouldReceive('get')
5761
->with(Platform::cwd('whisky.json'))
58-
->andReturn(<<<'JSON'
62+
->andReturn(<<<"JSON"
5963
{
6064
"disabled": [],
6165
"hooks": {
6266
"commit-msg": [
63-
"echo \"$1\" > /tmp/whisky_test_commit_msg"
67+
"echo \"$1\" > {$tmp_file}"
6468
]
6569
}
6670
}
@@ -69,10 +73,10 @@
6973
$this->artisan('run commit-msg ".git/COMMIT_EDITMSG"')
7074
->assertExitCode(0);
7175

72-
expect(file_get_contents('/tmp/whisky_test_commit_msg'))
76+
expect(file_get_contents($tmp_file))
7377
->toContain('.git/COMMIT_EDITMSG');
7478

75-
unlink('/tmp/whisky_test_commit_msg');
79+
unlink($tmp_file);
7680
});
7781

7882
it('still works if no arguments are passed to run command', function () {
@@ -84,21 +88,25 @@
8488
->with(Platform::cwd('.git/hooks/skip-once'))
8589
->andReturnFalse();
8690

91+
$tmp_file = Platform::temp_test_path('whisky_test_pre_commit');
92+
8793
File::shouldReceive('get')
8894
->with(Platform::cwd('whisky.json'))
89-
->andReturn(<<<'JSON'
95+
->andReturn(<<<"JSON"
9096
{
9197
"disabled": [],
9298
"hooks": {
9399
"pre-commit": [
94-
"echo \"pre-commit\" > /dev/null"
100+
"echo \"pre-commit\" > {$tmp_file}"
95101
]
96102
}
97103
}
98104
JSON);
99105

100106
$this->artisan('run pre-commit')
101107
->assertExitCode(0);
108+
109+
unlink($tmp_file);
102110
});
103111

104112
it('handles a missing expected argument gracefully', function () {
@@ -110,14 +118,16 @@
110118
->with(Platform::cwd('.git/hooks/skip-once'))
111119
->andReturnFalse();
112120

121+
$tmp_file = Platform::temp_test_path('whisky_test_commit_msg');
122+
113123
File::shouldReceive('get')
114124
->with(Platform::cwd('whisky.json'))
115-
->andReturn(<<<'JSON'
125+
->andReturn(<<<"JSON"
116126
{
117127
"disabled": [],
118128
"hooks": {
119129
"commit-msg": [
120-
"echo \"$1\" > /tmp/whisky_test_commit_msg"
130+
"echo \"$1\" > {$tmp_file}"
121131
]
122132
}
123133
}
@@ -126,8 +136,8 @@
126136
$this->artisan('run commit-msg')
127137
->assertExitCode(0);
128138

129-
expect(file_get_contents('/tmp/whisky_test_commit_msg'))
139+
expect(file_get_contents($tmp_file))
130140
->toBe("\n");
131141

132-
unlink('/tmp/whisky_test_commit_msg');
142+
unlink($tmp_file);
133143
});

0 commit comments

Comments
 (0)