-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* prepare members 2.5 sealing * remove empty tests * allow better exception handling in rest client * assert right https header * assert right https header * fix test include * fix travis
- Loading branch information
Showing
7 changed files
with
112 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace DachcomBundle\Test\Helper\Rest; | ||
|
||
use GuzzleHttp\Psr7\Request; | ||
use GuzzleHttp\Psr7\Response; | ||
use Symfony\Component\BrowserKit\Request as BrowserKitRequest; | ||
use Symfony\Component\BrowserKit\Response as BrowserKitResponse; | ||
|
||
class BrowserKitRestClient extends \Pimcore\Tests\Rest\BrowserKitRestClient | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getResponse($method, $uri, array $parameters = [], array $files = [], array $server = [], $content = null) | ||
{ | ||
$uri = $this->prepareUri($uri); | ||
$parameters = $this->prepareParameters($parameters); | ||
$server = $this->prepareHeaders($server); | ||
|
||
if (count($parameters) > 0) { | ||
$query = http_build_query($parameters); | ||
|
||
if (false === strpos($uri, '?')) { | ||
$uri .= '?' . $query; | ||
} else { | ||
$uri .= '&' . $query; | ||
} | ||
} | ||
|
||
codecept_debug('[BrowserKitRestClient] Requesting URI ' . $uri); | ||
|
||
$this->client->request($method, $uri, $parameters, $files, $server, $content); | ||
|
||
/** @var BrowserKitRequest $browserKitRequest */ | ||
$browserKitRequest = $this->client->getInternalRequest(); | ||
|
||
/** @var BrowserKitResponse $response */ | ||
$browserKitResponse = $this->client->getInternalResponse(); | ||
|
||
$headers = $browserKitRequest->getServer(); | ||
if (isset($headers['HTTPS'])) { | ||
$headers['HTTPS'] = (string) $headers['HTTPS']; | ||
} | ||
|
||
$request = new Request( | ||
$browserKitRequest->getMethod(), | ||
$browserKitRequest->getUri(), | ||
$headers, | ||
$browserKitRequest->getContent() | ||
); | ||
|
||
$response = new Response( | ||
$browserKitResponse->getStatus(), | ||
$browserKitResponse->getHeaders(), | ||
$browserKitResponse->getContent() | ||
); | ||
|
||
$this->lastRequest = $request; | ||
$this->lastResponse = $response; | ||
|
||
return $response; | ||
} | ||
} |
Empty file.
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,39 @@ | ||
<?php | ||
|
||
namespace DachcomBundle\Test\rest; | ||
|
||
use DachcomBundle\Test\Helper\Rest\BrowserKitRestClient; | ||
use DachcomBundle\Test\Util\MembersHelper; | ||
use Pimcore\Tests\Test\RestTestCase; | ||
|
||
abstract class AbstractRestTestCase extends RestTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->restClient = new BrowserKitRestClient($this->tester->getHttpClient()); | ||
|
||
if ($this->authenticateUser) { | ||
$this->restClient->setApiKey($this->tester->getRestApiKey($this->authenticateUser)); | ||
} | ||
} | ||
|
||
/** | ||
* Params which will be added to each request | ||
* | ||
* @return array | ||
*/ | ||
public function getGlobalRequestParams() | ||
{ | ||
return []; | ||
} | ||
|
||
protected function _after() | ||
{ | ||
MembersHelper::cleanUp(); | ||
MembersHelper::reCreateMembersStructure(); | ||
|
||
parent::_after(); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
<?php | ||
// Here you can initialize variables that will be available to your tests | ||
include __DIR__ . '/AbstractRestTestCase.php'; |