public function testConstructorWithNonStringOrResource() { $this->
expectException(\TypeError::
class);
new DataPart(new \
stdClass());
} public function testHeaders() { $p =
new DataPart('content'
);
$this->
assertEquals(new Headers( new ParameterizedHeader('Content-Type', 'application/octet-stream'
),
new UnstructuredHeader('Content-Transfer-Encoding', 'base64'
),
new ParameterizedHeader('Content-Disposition', 'attachment'
) ),
$p->
getPreparedHeaders());
$p =
new DataPart('content', 'photo.jpg', 'text/html'
);
$this->
assertEquals(new Headers( new ParameterizedHeader('Content-Type', 'text/html',
['name' => 'photo.jpg'
]),
new UnstructuredHeader('Content-Transfer-Encoding', 'base64'
),
new ParameterizedHeader('Content-Disposition', 'attachment',
['name' => 'photo.jpg', 'filename' => 'photo.jpg'
]) ),
$p->
getPreparedHeaders());
}