diff --git a/.travis.yml b/.travis.yml index 9820e425..fc1f6302 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ -sudo: required +sudo: true language: php addons: chrome: stable - mariadb: '10.1' - + mariadb: '10.2' +services: + - mysql env: global: - PIMCORE_ENVIRONMENT=test @@ -100,7 +101,7 @@ after_failure: script: - '$HOME/chromedriver --url-base=/wd/hub &' - - 'php ${TRAVIS_BUILD_DIR}/bin/console server:start 127.0.0.1:8080' + - 'php ${TRAVIS_BUILD_DIR}/bin/console server:start 127.0.0.1:8080 -d web' - 'php ${TRAVIS_BUILD_DIR}/bin/console server:status' - _etc/travis/script diff --git a/tests/_etc/travis/install b/tests/_etc/travis/install index 63dc8486..f9a4752a 100755 --- a/tests/_etc/travis/install +++ b/tests/_etc/travis/install @@ -69,6 +69,7 @@ do done ## install composer dependencies +rm composer.lock COMPOSER_MEMORY_LIMIT=-1 composer install --no-scripts diff --git a/tests/_support/Helper/Rest/BrowserKitRestClient.php b/tests/_support/Helper/Rest/BrowserKitRestClient.php new file mode 100644 index 00000000..1eccfe64 --- /dev/null +++ b/tests/_support/Helper/Rest/BrowserKitRestClient.php @@ -0,0 +1,64 @@ +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; + } +} \ No newline at end of file diff --git a/tests/acceptance/Restriction/AssetRestriction.php b/tests/acceptance/Restriction/AssetRestriction.php deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/rest/AbstractRestTestCase.php b/tests/rest/AbstractRestTestCase.php new file mode 100644 index 00000000..0573e1a5 --- /dev/null +++ b/tests/rest/AbstractRestTestCase.php @@ -0,0 +1,39 @@ +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(); + } +} diff --git a/tests/rest/ObjectTest.php b/tests/rest/ObjectTest.php index f05c32b0..212822d5 100644 --- a/tests/rest/ObjectTest.php +++ b/tests/rest/ObjectTest.php @@ -1,26 +1,16 @@