2
2
3
3
namespace React \Tests \Filesystem ;
4
4
5
- use React \EventLoop \LoopInterface ;
6
5
use React \Filesystem \AdapterInterface ;
7
6
use React \Filesystem \Node \FileInterface ;
8
7
use React \Filesystem \Node \NotExistInterface ;
9
8
use React \Filesystem \Stat ;
10
9
use React \Promise \Promise ;
11
10
use React \Promise \PromiseInterface ;
12
- use function Clue \ React \Block \await ;
11
+ use function React \Async \await ;
13
12
use function React \Promise \all ;
14
13
15
14
final class FileTest extends AbstractFilesystemTestCase
@@ -21,7 +20,7 @@ final class FileTest extends AbstractFilesystemTestCase
21
20
*/
22
21
public function stat (AdapterInterface $ filesystem ): void
23
22
{
24
- $ stat = $ this -> await ($ filesystem ->detect (__FILE__ )->then (static function (FileInterface $ file ): PromiseInterface {
23
+ $ stat = await ($ filesystem ->detect (__FILE__ )->then (static function (FileInterface $ file ): PromiseInterface {
25
24
return $ file ->stat ();
26
25
}));
27
26
@@ -36,7 +35,7 @@ public function stat(AdapterInterface $filesystem): void
36
35
*/
37
36
public function getContents (AdapterInterface $ filesystem ): void
38
37
{
39
- $ fileContents = $ this -> await ($ filesystem ->detect (__FILE__ )->then (static function (FileInterface $ file ): PromiseInterface {
38
+ $ fileContents = await ($ filesystem ->detect (__FILE__ )->then (static function (FileInterface $ file ): PromiseInterface {
40
39
return $ file ->getContents ();
41
40
}));
42
41
@@ -54,7 +53,7 @@ public function getContents34and5thCharacterFromFile(AdapterInterface $filesyste
54
53
$ fileName = $ directoryName . bin2hex (random_bytes (13 ));
55
54
mkdir ($ directoryName );
56
55
\file_put_contents ($ fileName , 'abcdefghijklmnopqrstuvwxyz ' );
57
- $ fileContents = $ this -> await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ): PromiseInterface {
56
+ $ fileContents = await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ): PromiseInterface {
58
57
return $ file ->getContents (3 , 3 );
59
58
}));
60
59
@@ -71,7 +70,7 @@ public function putContents(AdapterInterface $filesystem): void
71
70
$ fileName = sys_get_temp_dir () . DIRECTORY_SEPARATOR . bin2hex (random_bytes (13 )) . DIRECTORY_SEPARATOR . bin2hex (random_bytes (9 ));
72
71
$ fileContents = bin2hex (random_bytes (128 ));
73
72
74
- $ writtenLength = $ this -> await ($ filesystem ->detect ($ fileName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createFile ())->then (function (FileInterface $ file ) use ($ fileContents ): PromiseInterface {
73
+ $ writtenLength = await ($ filesystem ->detect ($ fileName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createFile ())->then (function (FileInterface $ file ) use ($ fileContents ): PromiseInterface {
75
74
return $ file ->putContents ($ fileContents );
76
75
}));
77
76
@@ -89,7 +88,7 @@ public function putContents(AdapterInterface $filesystem): void
89
88
public function putContentsMultipleBigFiles (AdapterInterface $ filesystem ): void
90
89
{
91
90
$ directoryName = sys_get_temp_dir () . DIRECTORY_SEPARATOR . bin2hex (random_bytes (13 )) . DIRECTORY_SEPARATOR ;
92
- $ this -> await ($ filesystem ->detect ($ directoryName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createDirectory ()));
91
+ await ($ filesystem ->detect ($ directoryName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createDirectory ()));
93
92
$ fileNames = [];
94
93
$ fileContents = [];
95
94
for ($ i = 0 ; $ i < 25 ; $ i ++) {
@@ -107,7 +106,7 @@ public function putContentsMultipleBigFiles(AdapterInterface $filesystem): void
107
106
});
108
107
}
109
108
110
- $ writtenLengths = $ this -> await (all ($ promises ));
109
+ $ writtenLengths = await (all ($ promises ));
111
110
112
111
foreach ($ writtenLengths as $ fileName => $ writtenLength ) {
113
112
self ::assertSame ($ writtenLength , strlen (file_get_contents ($ fileName )));
@@ -126,14 +125,14 @@ public function putContentsAppend(AdapterInterface $filesystem): void
126
125
$ fileName = sys_get_temp_dir () . DIRECTORY_SEPARATOR . bin2hex (random_bytes (13 )) . DIRECTORY_SEPARATOR . bin2hex (random_bytes (9 ));
127
126
$ fileContentsFirst = bin2hex (random_bytes (128 ));
128
127
$ fileContentsSecond = bin2hex (random_bytes (128 ));
129
- $ writtenLengthFirst = $ this -> await ($ filesystem ->detect ($ fileName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createFile ())->then (static function (FileInterface $ file ) use ($ fileContentsFirst ): PromiseInterface {
128
+ $ writtenLengthFirst = await ($ filesystem ->detect ($ fileName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createFile ())->then (static function (FileInterface $ file ) use ($ fileContentsFirst ): PromiseInterface {
130
129
return $ file ->putContents ($ fileContentsFirst );
131
130
}));
132
131
133
132
self ::assertSame ($ writtenLengthFirst , strlen (file_get_contents ($ fileName )));
134
133
self ::assertSame ($ fileContentsFirst , file_get_contents ($ fileName ));
135
134
136
- $ writtenLengthSecond = $ this -> await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ) use ($ fileContentsSecond ): PromiseInterface {
135
+ $ writtenLengthSecond = await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ) use ($ fileContentsSecond ): PromiseInterface {
137
136
return $ file ->putContents ($ fileContentsSecond , \FILE_APPEND );
138
137
}));
139
138
@@ -151,7 +150,7 @@ public function putContentsAppend(AdapterInterface $filesystem): void
151
150
public function putContentsAppendBigFile (AdapterInterface $ filesystem ): void
152
151
{
153
152
$ fileName = sys_get_temp_dir () . DIRECTORY_SEPARATOR . bin2hex (random_bytes (13 )) . DIRECTORY_SEPARATOR . bin2hex (random_bytes (9 ));
154
- $ this -> await ($ filesystem ->detect ($ fileName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createFile ()));
153
+ await ($ filesystem ->detect ($ fileName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createFile ()));
155
154
156
155
$ fileContents = [];
157
156
$ writtenLength = 0 ;
@@ -160,7 +159,7 @@ public function putContentsAppendBigFile(AdapterInterface $filesystem): void
160
159
}
161
160
162
161
foreach ($ fileContents as $ fileContent ) {
163
- $ writtenLength += $ this -> await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ) use ($ fileContent ): PromiseInterface {
162
+ $ writtenLength += await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ) use ($ fileContent ): PromiseInterface {
164
163
return $ file ->putContents ($ fileContent , \FILE_APPEND );
165
164
}));
166
165
}
@@ -246,7 +245,7 @@ public function runMultipleFilesTests(AdapterInterface $filesystem, int $fileCou
246
245
});
247
246
}
248
247
249
- $ writtenLengths = $ this -> await (all ($ promises ));
248
+ $ writtenLengths = await (all ($ promises ));
250
249
251
250
foreach ($ writtenLengths as $ fileName => $ writtenLength ) {
252
251
self ::assertSame ($ writtenLength , strlen (file_get_contents ($ fileName )));
@@ -266,7 +265,7 @@ public function unlink(AdapterInterface $filesystem): void
266
265
$ fileContents = bin2hex (random_bytes (2048 ));
267
266
file_put_contents ($ fileName , $ fileContents );
268
267
self ::assertFileExists ($ fileName );
269
- $ this -> await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ): PromiseInterface {
268
+ await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ): PromiseInterface {
270
269
return $ file ->unlink ();
271
270
}));
272
271
0 commit comments