2
2
3
3
namespace spec \TH \Lock ;
4
4
5
- use VirtualFileSystem \FileSystem ;
6
- use TH \Lock \FileLock ;
7
5
use PhpSpec \ObjectBehavior ;
8
6
use Prophecy \Argument ;
9
- use Exception ;
7
+ use TH \Lock \FileLock ;
8
+ use TH \Lock \Lock ;
9
+ use VirtualFileSystem \FileSystem ;
10
10
11
11
class FileLockSpec extends ObjectBehavior
12
12
{
@@ -25,20 +25,20 @@ public function let()
25
25
26
26
public function it_is_initializable ()
27
27
{
28
- $ this ->shouldHaveType (' TH\Lock\ FileLock' );
29
- $ this ->shouldImplement (' TH\ Lock\Lock ' );
28
+ $ this ->shouldHaveType (FileLock::class );
29
+ $ this ->shouldImplement (Lock::class );
30
30
}
31
31
32
32
public function it_should_acquire_an_exclusive_lock ()
33
33
{
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
40
if (flock (fopen ($ this ->lock_file , 'r ' ), LOCK_SH |LOCK_NB )) {
41
- throw new Exception ('Lock file was not exclusively locked ' );
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
55
if (flock (fopen ($ this ->lock_file , 'r ' ), LOCK_EX |LOCK_NB )) {
56
- throw new Exception ('Lock file was not locked againt exclusive lock ' );
56
+ throw new \ Exception ('Lock file was not locked againt exclusive lock ' );
57
57
}
58
58
59
59
if (!flock (fopen ($ this ->lock_file , 'r ' ), LOCK_SH |LOCK_NB )) {
60
- throw new Exception ('Lock file was not shared locked ' );
60
+ throw new \ Exception ('Lock file was not shared locked ' );
61
61
}
62
62
}
63
63
@@ -67,7 +67,7 @@ public function it_should_release_a_lock()
67
67
$ this ->release ();
68
68
69
69
if (!flock (fopen ($ this ->lock_file , 'r ' ), LOCK_EX |LOCK_NB )) {
70
- throw new Exception ('Lock file was not released ' );
70
+ throw new \ Exception ('Lock file was not released ' );
71
71
}
72
72
}
73
73
@@ -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
@@ -102,7 +102,7 @@ public function it_does_not_remove_its_lock_file_if_still_locked()
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
121
if (flock (fopen ($ this ->lock_file , 'r ' ), LOCK_SH |LOCK_NB )) {
122
- throw new Exception ('Lock file was not exclusively locked ' );
122
+ throw new \ Exception ('Lock file was not exclusively locked ' );
123
123
}
124
124
125
125
$ this ->release ();
0 commit comments