Skip to content

Commit 299b8cd

Browse files
committed
# 0.2.2 - 2016-08-28 - CHANGE FileSystemTestable trait constructor now accept a directory base.
1 parent 3ec45f4 commit 299b8cd

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All Notable changes to `test` will be documented in this file
44

5+
## 0.2.2 - 2016-08-28
6+
7+
- CHANGE FileSystemTestable trait constructor now accept a directory base.
8+
59
## 0.2.1 - 2016-08-28
610

711
- Update composer.json

src/traits/FileSystemTestable.php

+20-18
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ trait FileSystemTestable
66
{
77
/**
88
* Remove created path during test
9+
* @param $baseDir
910
*/
10-
protected function initFileAndPath()
11+
protected function initFileAndPath($baseDir)
1112
{
12-
$dir = __DIR__ . '/resources/';
13+
$dir = $baseDir . '/resources/';
1314
if (!is_dir($dir)) {
1415
mkdir($dir, '0777', true);
1516
}
@@ -24,7 +25,7 @@ protected function initFileAndPath()
2425
file_put_contents($file, 'dummy;');
2526
}
2627

27-
$dir = __DIR__ . '/resources/subdir/';
28+
$dir = $baseDir . '/resources/subdir/';
2829
if (!is_dir($dir)) {
2930
mkdir($dir, '0777', true);
3031
}
@@ -37,30 +38,31 @@ protected function initFileAndPath()
3738

3839
/**
3940
* Remove created path during test
41+
* @param $baseDir
4042
*/
41-
protected function removeCreatedPathDuringTest()
43+
protected function removeCreatedPathDuringTest($baseDir)
4244
{
43-
if (is_dir(__DIR__ . '/pippo.txt')) {
44-
rmdir(__DIR__ . '/pippo.txt');
45+
if (is_dir($baseDir . '/pippo.txt')) {
46+
rmdir($baseDir . '/pippo.txt');
4547
}
46-
if (is_dir(__DIR__ . '/dummy/')) {
47-
rmdir(__DIR__ . '/dummy/');
48+
if (is_dir($baseDir . '/dummy/')) {
49+
rmdir($baseDir . '/dummy/');
4850
}
49-
if (file_exists(__DIR__ . '/resources/new/dummy.txt')) {
50-
unlink(__DIR__ . '/resources/new/dummy.txt');
51+
if (file_exists($baseDir . '/resources/new/dummy.txt')) {
52+
unlink($baseDir . '/resources/new/dummy.txt');
5153
}
52-
if (is_dir(__DIR__ . '/resources/new/')) {
53-
rmdir(__DIR__ . '/resources/new/');
54+
if (is_dir($baseDir . '/resources/new/')) {
55+
rmdir($baseDir . '/resources/new/');
5456
}
55-
if (file_exists(__DIR__ . '/resources/new2/dummy.txt')) {
56-
unlink(__DIR__ . '/resources/new2/dummy.txt');
57+
if (file_exists($baseDir . '/resources/new2/dummy.txt')) {
58+
unlink($baseDir . '/resources/new2/dummy.txt');
5759
}
58-
if (is_dir(__DIR__ . '/resources/new2/')) {
59-
rmdir(__DIR__ . '/resources/new2/');
60+
if (is_dir($baseDir . '/resources/new2/')) {
61+
rmdir($baseDir . '/resources/new2/');
6062
}
6163

6264
/*
63-
$dir = __DIR__ . '/resources/subdir/';
65+
$dir = $baseDir . '/resources/subdir/';
6466
6567
$file = $dir . 'dummy.txt';
6668
if (file_exists($file)) {
@@ -70,7 +72,7 @@ protected function removeCreatedPathDuringTest()
7072
rmdir($dir);
7173
}
7274
73-
$dir = __DIR__ . '/resources/';
75+
$dir = $baseDir . '/resources/';
7476
7577
$file = $dir . 'dummy.txt';
7678
if (file_exists($file)) {

0 commit comments

Comments
 (0)