forked from Sylius/Sylius
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor Sylius#13896 [behat]Extract Request creation to separate ser…
…vice (Ferror) This PR was merged into the 1.12-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | none | License | MIT It is a part of improving Developer Experience in Behat tests. I removed factory methods out of the Request class, as the object has really grown up. Moved these methods to separate Factory required a lot of changes, that's why I decided to postpone here and merge current changes. Created Request Builder and Factory will provide an additional layer for future developers to build their own Requests Commits ------- 77b515e Extract building and creating Request object outside of API client
- Loading branch information
Showing
21 changed files
with
612 additions
and
443 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,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Behat\Client; | ||
|
||
use Symfony\Component\HttpFoundation\Request as HttpRequest; | ||
|
||
class ContentTypeGuide implements ContentTypeGuideInterface | ||
{ | ||
private const JSON_CONTENT_TYPE = 'application/json'; | ||
private const PATCH_CONTENT_TYPE = 'application/merge-patch+json'; | ||
private const LINKED_DATA_JSON_CONTENT_TYPE = 'application/ld+json'; | ||
|
||
public function guide(string $method): string | ||
{ | ||
if ($method === HttpRequest::METHOD_PATCH) { | ||
return self::PATCH_CONTENT_TYPE; | ||
} | ||
|
||
if ($method === HttpRequest::METHOD_PUT) { | ||
return self::LINKED_DATA_JSON_CONTENT_TYPE; | ||
} | ||
|
||
return self::JSON_CONTENT_TYPE; | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Behat\Client; | ||
|
||
interface ContentTypeGuideInterface | ||
{ | ||
public function guide(string $method): string; | ||
} |
Oops, something went wrong.