14
14
15
15
namespace chillerlan \HTTPTest \Psr7 ;
16
16
17
+ use chillerlan \HTTP \Psr17 ;
17
18
use chillerlan \HTTP \Psr7 ;
18
19
use chillerlan \HTTP \Psr7 \UploadedFile ;
19
- use chillerlan \HTTP \Psr17 \{StreamFactory , UploadedFileFactory };
20
20
use InvalidArgumentException ;
21
21
use PHPUnit \Framework \TestCase ;
22
22
@@ -27,20 +27,8 @@ class UploadedFileTest extends TestCase{
27
27
*/
28
28
protected $ cleanup ;
29
29
30
- /**
31
- * @var \chillerlan\HTTP\Psr17\UploadedFileFactory
32
- */
33
- protected $ uploadedFileFactory ;
34
-
35
- /**
36
- * @var \chillerlan\HTTP\Psr17\StreamFactory
37
- */
38
- protected $ streamFactory ;
39
-
40
30
protected function setUp ():void {
41
31
$ this ->cleanup = [];
42
- $ this ->uploadedFileFactory = new UploadedFileFactory ;
43
- $ this ->streamFactory = new StreamFactory ;
44
32
}
45
33
46
34
protected function tearDown ():void {
@@ -93,8 +81,8 @@ public function testRaisesExceptionOnInvalidErrorStatus(int $status){
93
81
}
94
82
95
83
public function testGetStreamReturnsOriginalStreamObject (){
96
- $ stream = $ this -> streamFactory -> createStream ('' );
97
- $ upload = $ this -> uploadedFileFactory -> createUploadedFile ($ stream , 0 , UPLOAD_ERR_OK ); // coverage
84
+ $ stream = Psr17 \create_stream ('' );
85
+ $ upload = new UploadedFile ($ stream , 0 , UPLOAD_ERR_OK );
98
86
99
87
$ this ->assertSame ($ stream , $ upload ->getStream ());
100
88
}
@@ -108,7 +96,7 @@ public function testGetStreamReturnsWrappedPhpStream(){
108
96
}
109
97
110
98
public function testSuccessful (){
111
- $ stream = $ this -> streamFactory -> createStream ('Foo bar! ' );
99
+ $ stream = Psr17 \create_stream ('Foo bar! ' );
112
100
$ upload = new UploadedFile ($ stream , $ stream ->getSize (), UPLOAD_ERR_OK , 'filename.txt ' , 'text/plain ' );
113
101
114
102
$ this ->assertEquals ($ stream ->getSize (), $ upload ->getSize ());
@@ -123,7 +111,7 @@ public function testSuccessful(){
123
111
}
124
112
125
113
public function testMoveCannotBeCalledMoreThanOnce (){
126
- $ stream = $ this -> streamFactory -> createStream ('Foo bar! ' );
114
+ $ stream = Psr17 \create_stream ('Foo bar! ' );
127
115
$ upload = new UploadedFile ($ stream , 0 , UPLOAD_ERR_OK );
128
116
129
117
$ this ->cleanup [] = $ to = tempnam (sys_get_temp_dir (), 'diac ' );
@@ -136,7 +124,7 @@ public function testMoveCannotBeCalledMoreThanOnce(){
136
124
}
137
125
138
126
public function testCannotRetrieveStreamAfterMove (){
139
- $ stream = $ this -> streamFactory -> createStream ('Foo bar! ' );
127
+ $ stream = Psr17 \create_stream ('Foo bar! ' );
140
128
$ upload = new UploadedFile ($ stream , 0 , UPLOAD_ERR_OK );
141
129
142
130
$ this ->cleanup [] = $ to = tempnam (sys_get_temp_dir (), 'diac ' );
0 commit comments