bug #11560 [HOTFIX] Fix build (Tomanhez)

This PR was merged into the 1.7-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| License         | MIT

Fix build and improve `getError()` more usable 


Commits
-------

392982c6fc Add fix for getError() metchod
c659707a30 modify chrome travis run command
This commit is contained in:
Łukasz Chruściel 2020-06-09 14:13:54 +02:00 committed by GitHub
commit e18f1b820e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View file

@ -7,7 +7,7 @@ prepare_for_behat_with_js() {
run_command "$SYLIUS_CACHE_DIR/symfony server:ca:install"
# Run headless Chrome
run_command "google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 &"
run_command "google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --disable-gpu --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 &"
# Run webserver
run_command "$SYLIUS_CACHE_DIR/symfony server:start --port=8080 --dir=public --daemon"

View file

@ -50,6 +50,10 @@ final class ResponseChecker implements ResponseCheckerInterface
public function getError(Response $response): string
{
if ($this->hasKey($response, 'message')) {
return $this->getValue($response, 'message');
}
return $this->getResponseContentValue($response, 'hydra:description');
}
@ -121,6 +125,13 @@ final class ResponseChecker implements ResponseCheckerInterface
return false;
}
public function hasKey(Response $response, string $key): bool
{
$content = json_decode($response->getContent(), true);
return array_key_exists($key, $content);
}
public function hasTranslation(Response $response, string $locale, string $key, string $translation): bool
{
$resource = $this->getResponseContent($response);

View file

@ -44,11 +44,16 @@ interface ResponseCheckerInterface
/** @param string|int $value */
public function hasItemWithValue(Response $response, string $key, $value): bool;
/** @param string|int $value */
public function hasSubResourceWithValue(Response $response, string $subResource, string $key, $value): bool;
/** @param string|array $value */
public function hasItemOnPositionWithValue(Response $response, int $position, string $key, $value): bool;
public function hasItemWithTranslation(Response $response, string $locale, string $key, string $translation): bool;
public function hasKey(Response $response, string $key): bool;
public function hasTranslation(Response $response, string $locale, string $key, string $translation): bool;
public function hasItemWithValues(Response $response, array $parameters): bool;