2023-02-23 22:43:13 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Lib;
|
|
|
|
|
|
|
|
use Illuminate\Testing\TestResponse;
|
|
|
|
|
|
|
|
trait MakesHttpCalls
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param array<string, mixed> $filter
|
|
|
|
*/
|
|
|
|
public function callFilter(string $routeName, array $filter): TestResponse
|
|
|
|
{
|
|
|
|
return $this->call('GET', $this->filterUrl($routeName, $filter));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array<string, mixed> $filter
|
|
|
|
*/
|
|
|
|
public function filterUrl(string $routeName, array $filter): string
|
|
|
|
{
|
|
|
|
$params = [
|
2024-01-30 00:49:22 +01:00
|
|
|
'filter' => $this->filterString($filter),
|
2023-02-23 22:43:13 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
return route($routeName, $params);
|
|
|
|
}
|
2024-01-30 00:49:22 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array<string, mixed> $filter
|
|
|
|
*/
|
|
|
|
public function filterString(array $filter): string
|
|
|
|
{
|
|
|
|
return base64_encode(rawurlencode(json_encode($filter)));
|
|
|
|
}
|
2023-02-23 22:43:13 +01:00
|
|
|
}
|