-
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.
* develop: add first implementation add cs config
- Loading branch information
Showing
15 changed files
with
736 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
return Innmind\CodingStandard\CodingStandard::config([ | ||
'src', | ||
]); |
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 was deleted.
Oops, something went wrong.
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,12 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace App; | ||
|
||
use Symfony\Component\HttpKernel\Kernel as BaseKernel; | ||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; | ||
|
||
final class Kernel extends BaseKernel | ||
{ | ||
use MicroKernelTrait; | ||
} |
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,100 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Innmind\BlackBox\Symfony; | ||
|
||
use Innmind\BlackBox\Runner\Assert; | ||
|
||
final class Application | ||
{ | ||
private Assert $assert; | ||
private ?Browser $browser = null; | ||
|
||
private function __construct(Assert $assert) | ||
{ | ||
$this->assert = $assert; | ||
} | ||
|
||
public static function new(Assert $assert): self | ||
{ | ||
return new self($assert); | ||
} | ||
|
||
/** | ||
* @param non-empty-string $uri | ||
*/ | ||
public function get(string $uri, array $headers = []): Response | ||
{ | ||
return $this->request('GET', $uri); | ||
} | ||
|
||
/** | ||
* @param non-empty-string $uri | ||
*/ | ||
public function post(string $uri, array $data = [], array $headers = []): Response | ||
{ | ||
return $this->request('POST', $uri, $data, [], $headers); | ||
} | ||
|
||
/** | ||
* @param non-empty-string $uri | ||
*/ | ||
public function put(string $uri, array $data = [], array $headers = []): Response | ||
{ | ||
return $this->request('PUT', $uri, $data, [], $headers); | ||
} | ||
|
||
/** | ||
* @param non-empty-string $uri | ||
*/ | ||
public function delete(string $uri, array $data = [], array $headers = []): Response | ||
{ | ||
return $this->request('DELETE', $uri, $data, [], $headers); | ||
} | ||
|
||
public function upload(): Upload | ||
{ | ||
return Upload::of($this); | ||
} | ||
|
||
/** | ||
* @param non-empty-string $method | ||
* @param non-empty-string $uri | ||
*/ | ||
public function request( | ||
string $method, | ||
string $uri, | ||
array $post = [], | ||
array $files = [], | ||
array $headers = [], | ||
string $rawBody = '', | ||
): Response { | ||
// Symfony cast all values from this array in the BrowserKit Request to | ||
// simulate that everything goes through as as string via multipart but | ||
// it uses a simple cast and it differs from how a real browser will | ||
// cast booleans, so we do this transformation here | ||
\array_walk_recursive($post, static function(mixed &$value) { | ||
if ($value === true) { | ||
$value = 'true'; | ||
} | ||
|
||
if ($value === false) { | ||
$value = 'false'; | ||
} | ||
}); | ||
|
||
$client = $this->browser()->client(); | ||
$client->request($method, $uri, $post, $files, $headers, $rawBody); | ||
|
||
return Response::new( | ||
$this->assert, | ||
$client->getResponse(), | ||
$client->getInternalResponse(), | ||
); | ||
} | ||
|
||
private function browser(): Browser | ||
{ | ||
return $this->browser ??= Browser::new(); | ||
} | ||
} |
Oops, something went wrong.