@@ -16,7 +16,7 @@ class FileLockSpec extends ObjectBehavior
16
16
public function let ()
17
17
{
18
18
$ this ->fs = new FileSystem ;
19
- $ this ->lock_file = $ this ->fs ->path (' /path/to/lock_file.lock ' );
19
+ $ this ->lock_file = $ this ->fs ->path (" /path/to/lock_file.lock " );
20
20
21
21
mkdir (dirname ($ this ->lock_file ), 0777 , true );
22
22
@@ -34,11 +34,11 @@ public function it_should_acquire_an_exclusive_lock()
34
34
$ this ->acquire ();
35
35
36
36
if (!file_exists ($ this ->lock_file )) {
37
- throw new \Exception (' Lock file was not created ' );
37
+ throw new \Exception (" Lock file was not created " );
38
38
}
39
39
40
- if (flock (fopen ($ this ->lock_file , ' r ' ), LOCK_SH |LOCK_NB )) {
41
- throw new \Exception (' Lock file was not exclusively locked ' );
40
+ if (flock (fopen ($ this ->lock_file , " r " ), LOCK_SH |LOCK_NB )) {
41
+ throw new \Exception (" Lock file was not exclusively locked " );
42
42
}
43
43
}
44
44
@@ -49,15 +49,15 @@ public function it_should_acquire_a_shared_lock()
49
49
$ this ->acquire ();
50
50
51
51
if (!file_exists ($ this ->lock_file )) {
52
- throw new \Exception (' Lock file was not created ' );
52
+ throw new \Exception (" Lock file was not created " );
53
53
}
54
54
55
- if (flock (fopen ($ this ->lock_file , ' r ' ), LOCK_EX |LOCK_NB )) {
56
- throw new \Exception (' Lock file was not locked againt exclusive lock ' );
55
+ if (flock (fopen ($ this ->lock_file , " r " ), LOCK_EX |LOCK_NB )) {
56
+ throw new \Exception (" Lock file was not locked againt exclusive lock " );
57
57
}
58
58
59
- if (!flock (fopen ($ this ->lock_file , ' r ' ), LOCK_SH |LOCK_NB )) {
60
- throw new \Exception (' Lock file was not shared locked ' );
59
+ if (!flock (fopen ($ this ->lock_file , " r " ), LOCK_SH |LOCK_NB )) {
60
+ throw new \Exception (" Lock file was not shared locked " );
61
61
}
62
62
}
63
63
@@ -66,15 +66,15 @@ public function it_should_release_a_lock()
66
66
$ this ->acquire ();
67
67
$ this ->release ();
68
68
69
- if (!flock (fopen ($ this ->lock_file , ' r ' ), LOCK_EX |LOCK_NB )) {
70
- throw new \Exception (' Lock file was not released ' );
69
+ if (!flock (fopen ($ this ->lock_file , " r " ), LOCK_EX |LOCK_NB )) {
70
+ throw new \Exception (" Lock file was not released " );
71
71
}
72
72
}
73
73
74
74
public function it_should_throw_if_it_cannot_lock ()
75
75
{
76
76
touch ($ this ->lock_file );
77
- flock (fopen ($ this ->lock_file , ' r ' ), LOCK_SH |LOCK_NB );
77
+ flock (fopen ($ this ->lock_file , " r " ), LOCK_SH |LOCK_NB );
78
78
79
79
$ this ->shouldThrow ()->duringAcquire ();
80
80
}
@@ -87,7 +87,7 @@ public function it_remove_its_lock_file_if_not_locked()
87
87
$ this ->release ();
88
88
89
89
if (file_exists ($ this ->lock_file )) {
90
- throw new \Exception (' Lock file was not removed ' );
90
+ throw new \Exception (" Lock file was not removed " );
91
91
}
92
92
}
93
93
@@ -96,13 +96,13 @@ public function it_does_not_remove_its_lock_file_if_still_locked()
96
96
$ this ->beConstructedWith ($ this ->lock_file , FileLock::SHARED , FileLock::NON_BLOCKING , true );
97
97
98
98
touch ($ this ->lock_file );
99
- flock (fopen ($ this ->lock_file , ' r ' ), LOCK_SH |LOCK_NB );
99
+ flock (fopen ($ this ->lock_file , " r " ), LOCK_SH |LOCK_NB );
100
100
101
101
$ this ->acquire ();
102
102
$ this ->release ();
103
103
104
104
if (!file_exists ($ this ->lock_file )) {
105
- throw new \Exception (' Lock file was removed ' );
105
+ throw new \Exception (" Lock file was removed " );
106
106
}
107
107
}
108
108
@@ -115,11 +115,11 @@ public function it_can_acquire_then_release_and_acquire_again()
115
115
$ this ->acquire ();
116
116
117
117
if (!file_exists ($ this ->lock_file )) {
118
- throw new \Exception (' Lock file was not created ' );
118
+ throw new \Exception (" Lock file was not created " );
119
119
}
120
120
121
- if (flock (fopen ($ this ->lock_file , ' r ' ), LOCK_SH |LOCK_NB )) {
122
- throw new \Exception (' Lock file was not exclusively locked ' );
121
+ if (flock (fopen ($ this ->lock_file , " r " ), LOCK_SH |LOCK_NB )) {
122
+ throw new \Exception (" Lock file was not exclusively locked " );
123
123
}
124
124
125
125
$ this ->release ();
0 commit comments