This repository has been archived by the owner on Jun 13, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
140 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--boundary | ||
Content-Disposition: form-data; name="XML Payload" | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<UploadSiteHostedPicturesRequest xmlns="urn:ebay:apis:eBLBaseComponents"><PictureName>Example Picture</PictureName></UploadSiteHostedPicturesRequest> | ||
--boundary | ||
Content-Disposition: form-data; name="Example Picture"; filename="picture" | ||
Content-Type: image/jpeg | ||
|
||
ABC123 | ||
--boundary-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
namespace DTS\eBaySDK\Types\Test; | ||
|
||
use DTS\eBaySDK\Trading\Services; | ||
use DTS\eBaySDK\Trading\Types; | ||
use DTS\eBaySDK\Test\Mocks\HttpHandler; | ||
|
||
class MultipartFormDataTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
private $httpHandler; | ||
private $service; | ||
private $request; | ||
private $requestXml; | ||
|
||
protected function setUp() | ||
{ | ||
/** | ||
* Use a class that will fake sending requests and getting responses. | ||
* The idea is that all the information needed to make the request is | ||
* passed to the client by the service. What we want to test is that the | ||
* is actually passed correctly. We are not testing the sending of the request | ||
* over the internet. | ||
* The HttpHandler contains properties that will be set when the service | ||
* makes the request. We can test these properties to check what the service is passing. | ||
*/ | ||
$this->httpHandler = new HttpHandler(); | ||
$this->service = new Services\TradingService([ | ||
'apiVersion' => '123', | ||
'credentials' => ['appId' => '', 'certId' => '', 'devId' => ''], | ||
'siteId' => 0, | ||
'httpHandler' => $this->httpHandler | ||
]); | ||
$this->request = new Types\UploadSiteHostedPicturesRequestType(); | ||
$this->request->PictureName = 'Example Picture'; | ||
$this->requestXml = rtrim(file_get_contents(__DIR__.'/../../Mocks/MultipartFormDataRequest')); | ||
} | ||
|
||
public function testHttpHeadersAreCreated() | ||
{ | ||
$this->request->attachment('ABC123', 'image/jpeg'); | ||
$this->service->uploadSiteHostedPictures($this->request); | ||
$this->assertArrayHasKey('Content-Type', $this->httpHandler->headers); | ||
$this->assertEquals('multipart/form-data;boundary="boundary"', $this->httpHandler->headers['Content-Type']); | ||
$this->assertArrayHasKey('Content-Length', $this->httpHandler->headers); | ||
$this->assertEquals(strlen($this->requestXml), $this->httpHandler->headers['Content-Length']); | ||
} | ||
|
||
public function testMultipartFormDataIsCreated() | ||
{ | ||
$this->request->attachment('ABC123', 'image/jpeg'); | ||
$this->service->uploadSiteHostedPictures($this->request); | ||
$this->assertEquals($this->requestXml, $this->httpHandler->body); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters