@@ -134,6 +134,30 @@ public function testFromPathWithNotAFile()
134
134
DataPart::fromPath (__DIR__ .'/../Fixtures/mimetypes/ ' );
135
135
}
136
136
137
+ /**
138
+ * @group network
139
+ */
140
+ public function testFromPathWithUrl ()
141
+ {
142
+ if (!\in_array ('https ' , stream_get_wrappers ())) {
143
+ $ this ->markTestSkipped ('"https" stream wrapper is not enabled. ' );
144
+ }
145
+
146
+ $ p = DataPart::fromPath ($ file = 'https://symfony.com/images/common/logo/logo_symfony_header.png ' );
147
+ $ content = file_get_contents ($ file );
148
+ $ this ->assertEquals ($ content , $ p ->getBody ());
149
+ $ maxLineLength = 76 ;
150
+ $ this ->assertEquals (substr (base64_encode ($ content ), 0 , $ maxLineLength ), substr ($ p ->bodyToString (), 0 , $ maxLineLength ));
151
+ $ this ->assertEquals (substr (base64_encode ($ content ), 0 , $ maxLineLength ), substr (implode ('' , iterator_to_array ($ p ->bodyToIterable ())), 0 , $ maxLineLength ));
152
+ $ this ->assertEquals ('image ' , $ p ->getMediaType ());
153
+ $ this ->assertEquals ('png ' , $ p ->getMediaSubType ());
154
+ $ this ->assertEquals (new Headers (
155
+ new ParameterizedHeader ('Content-Type ' , 'image/png ' , ['name ' => 'logo_symfony_header.png ' ]),
156
+ new UnstructuredHeader ('Content-Transfer-Encoding ' , 'base64 ' ),
157
+ new ParameterizedHeader ('Content-Disposition ' , 'attachment ' , ['name ' => 'logo_symfony_header.png ' , 'filename ' => 'logo_symfony_header.png ' ])
158
+ ), $ p ->getPreparedHeaders ());
159
+ }
160
+
137
161
public function testHasContentId ()
138
162
{
139
163
$ p = new DataPart ('content ' );
0 commit comments