File tree Expand file tree Collapse file tree 3 files changed +118
-178
lines changed Expand file tree Collapse file tree 3 files changed +118
-178
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace ZipStream \Test ;
6
+
7
+ trait Tempfile
8
+ {
9
+ protected string |null $ tempfile ;
10
+
11
+ /**
12
+ * @var resource
13
+ */
14
+ protected $ tempfileStream ;
15
+
16
+ protected function setUp (): void
17
+ {
18
+ [$ tempfile , $ tempfileStream ] = $ this ->getTmpFileStream ();
19
+
20
+ $ this ->tempfile = $ tempfile ;
21
+ $ this ->tempfileStream = $ tempfileStream ;
22
+ }
23
+
24
+ protected function tearDown (): void
25
+ {
26
+ unlink ($ this ->tempfile );
27
+ if (is_resource ($ this ->tempfileStream )) {
28
+ fclose ($ this ->tempfileStream );
29
+ }
30
+
31
+ $ this ->tempfile = null ;
32
+ $ this ->tempfileStream = null ;
33
+ }
34
+
35
+ protected function getTmpFileStream (): array
36
+ {
37
+ $ tmp = tempnam (sys_get_temp_dir (), 'zipstreamtest ' );
38
+ $ stream = fopen ($ tmp , 'wb+ ' );
39
+
40
+ return [$ tmp , $ stream ];
41
+ }
42
+ }
Original file line number Diff line number Diff line change 18
18
19
19
trait Util
20
20
{
21
- protected function getTmpFileStream (): array
22
- {
23
- $ tmp = tempnam (sys_get_temp_dir (), 'zipstreamtest ' );
24
- $ stream = fopen ($ tmp , 'wb+ ' );
25
-
26
- return [$ tmp , $ stream ];
27
- }
28
-
29
21
protected function cmdExists (string $ command ): bool
30
22
{
31
23
if (strtolower (\substr (PHP_OS , 0 , 3 )) === 'win ' ) {
You can’t perform that action at this time.
0 commit comments