File tree 2 files changed +17
-7
lines changed
2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ public function save(string $filepath): void
70
70
}
71
71
72
72
// write data
73
- $ saved = @file_put_contents ($ filepath , $ this ->pointer );
73
+ $ saved = @file_put_contents ($ filepath , $ this ->toFilePointer () );
74
74
if ($ saved === false ) {
75
75
throw new NotWritableException (
76
76
sprintf ("Can't write image data to path (%s). " , $ filepath )
@@ -85,7 +85,7 @@ public function save(string $filepath): void
85
85
*/
86
86
public function toString (): string
87
87
{
88
- return stream_get_contents ($ this ->pointer , offset: 0 );
88
+ return stream_get_contents ($ this ->toFilePointer () , offset: 0 );
89
89
}
90
90
91
91
/**
@@ -107,7 +107,7 @@ public function toFilePointer()
107
107
*/
108
108
public function size (): int
109
109
{
110
- $ info = fstat ($ this ->pointer );
110
+ $ info = fstat ($ this ->toFilePointer () );
111
111
112
112
return intval ($ info ['size ' ]);
113
113
}
Original file line number Diff line number Diff line change @@ -41,11 +41,21 @@ public function testFromPath(): void
41
41
42
42
public function testSave (): void
43
43
{
44
- $ filename = __DIR__ . '/file_ ' . strval (hrtime (true )) . '.test ' ;
45
44
$ file = new File ('foo ' );
46
- $ file ->save ($ filename );
47
- $ this ->assertTrue (file_exists ($ filename ));
48
- unlink ($ filename );
45
+ $ filenames = [
46
+ __DIR__ . '/01_file_ ' . strval (hrtime (true )) . '.test ' ,
47
+ __DIR__ . '/02_file_ ' . strval (hrtime (true )) . '.test ' ,
48
+ ];
49
+
50
+ foreach ($ filenames as $ name ) {
51
+ $ file ->save ($ name );
52
+ }
53
+
54
+ foreach ($ filenames as $ name ) {
55
+ $ this ->assertFileExists ($ name );
56
+ $ this ->assertEquals ('foo ' , file_get_contents ($ name ));
57
+ unlink ($ name );
58
+ }
49
59
}
50
60
51
61
public function testToString (): void
You can’t perform that action at this time.
0 commit comments