Skip to content

Commit 3e1d8be

Browse files
committed
tests: fix tests and add documentation
1 parent 31dd112 commit 3e1d8be

53 files changed

Lines changed: 2226 additions & 385 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/Http/Controllers/RoomController.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use App\Models\Attachment;
66
use App\Models\Message;
77
use App\Models\User;
8-
use App\Services\Api\ApiRequestMigrator;
98
use App\Services\Chat\Message\MessageContentValidator;
109
use App\Services\Chat\Room\RoomService;
1110
use App\Services\Storage\FileStorageService;
@@ -158,10 +157,8 @@ public function searchUser(Request $request): JsonResponse
158157

159158

160159
// SECTION: MESSAGE
161-
public function sendMessage(Request $request, $slug, MessageContentValidator $contentValidator, ApiRequestMigrator $requestMigrator): JsonResponse
160+
public function sendMessage(Request $request, $slug, MessageContentValidator $contentValidator): JsonResponse
162161
{
163-
164-
$request = $requestMigrator->migrate($request);
165162
$validatedData = $request->validate([
166163
'content' => 'required|array',
167164
'metadata' => 'nullable|array',
@@ -182,9 +179,8 @@ public function sendMessage(Request $request, $slug, MessageContentValidator $co
182179
}
183180

184181

185-
public function updateMessage(Request $request, $slug, ApiRequestMigrator $requestMigrator): JsonResponse
182+
public function updateMessage(Request $request, $slug): JsonResponse
186183
{
187-
$request = $requestMigrator->migrate($request);
188184
$validatedData = $request->validate([
189185
'content' => 'required|array',
190186
'metadata' => 'nullable|array',
@@ -214,9 +210,8 @@ public function retrieveMessage($slug, $message_id): JsonResponse
214210
}
215211

216212

217-
public function markAsRead(Request $request, $slug, ApiRequestMigrator $migrator): JsonResponse
213+
public function markAsRead(Request $request, $slug): JsonResponse
218214
{
219-
$request = $migrator->migrate($request);
220215
$validatedData = $request->validate([
221216
'message_id' => 'required|string',
222217
]);

app/Http/Controllers/StreamController.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
use App\Services\Ai\Values\Chunks\MaxToolExecutionsChunk;
1717
use App\Services\Ai\Values\Chunks\StreamDoneChunk;
1818
use App\Services\Ai\Values\TokenUsage;
19-
use App\Services\Api\ApiRequestMigrator;
20-
use App\Services\Api\Value\ApiRequestFieldConfig;
2119
use App\Services\Chat\Message\Handlers\GroupMessageHandler;
2220
use App\Services\Storage\AvatarStorageService;
2321
use App\Services\Storage\Values\StoredFileIdentifier;
@@ -87,12 +85,8 @@ public function handleExternalRequest(Request $request)
8785
/**
8886
* Handle AI connection requests using the new architecture
8987
*/
90-
public function handleAiConnectionRequest(Request $request, ApiRequestMigrator $requestMigrator)
88+
public function handleAiConnectionRequest(Request $request)
9189
{
92-
$request = $requestMigrator->migrate(
93-
$request,
94-
new ApiRequestFieldConfig(messageIdField: 'messageId', threadIdField: 'threadIndex')
95-
);
9690

9791
//validate payload
9892
try {

app/Services/Ai/Values/ModelCapabilities.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
*
5555
* @api
5656
*/
57-
final class ModelCapabilities implements \JsonSerializable, CastableInstanceInterface
57+
class ModelCapabilities implements \JsonSerializable, CastableInstanceInterface
5858
{
5959
use Macroable;
6060

app/Services/Ai/Values/ProviderSettings.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
*
4646
* @api
4747
*/
48-
final class ProviderSettings implements CastableInstanceInterface
48+
final class ProviderSettings implements CastableInstanceInterface, \JsonSerializable
4949
{
5050
use Macroable;
5151

@@ -153,7 +153,7 @@ public function set(string $key, mixed $value): self
153153
*/
154154
public function remove(string $key): self
155155
{
156-
if (in_array($key, $this->instanceKeys, true)) {
156+
if (array_key_exists($key, $this->instanceKeys)) {
157157
throw InvalidProviderSettingsOperationException::forRequiredInstanceKey($key);
158158
}
159159

@@ -179,7 +179,7 @@ public static function fromArray(array $data): static
179179
public function toArray(): array
180180
{
181181
$data = $this->list;
182-
foreach ($this->instanceKeys as $key) {
182+
foreach (array_keys($this->instanceKeys) as $key) {
183183
if (isset($data[$key]) && $data[$key] instanceof CastableInstanceInterface) {
184184
$data[$key] = $data[$key]->toArray();
185185
if (empty($data[$key])) {
@@ -189,4 +189,10 @@ public function toArray(): array
189189
}
190190
return $data;
191191
}
192+
193+
/** Serializes to a plain array, identical to {@see toArray()}. */
194+
public function jsonSerialize(): array
195+
{
196+
return $this->toArray();
197+
}
192198
}

app/Services/Api/ApiRequestMigrator.php

Lines changed: 0 additions & 119 deletions
This file was deleted.

app/Services/Api/Value/ApiRequestFieldConfig.php

Lines changed: 0 additions & 50 deletions
This file was deleted.

app/Services/System/Container/ServiceLocator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public function set(string $id, mixed $service): self
5959
* Resolves the service registered under the given identifier.
6060
*
6161
* Resolution order:
62-
* 1. Locally registered services (see {@see set()})
63-
* 2. The injected container (see {@see setContainer()})
62+
* 1. Locally registered services ({@see set()})
63+
* 2. The injected container ({@see setContainer()})
6464
*
6565
* @throws ServiceLocatorException when the service is not found locally and no container is available.
6666
*/
@@ -82,7 +82,7 @@ public function get(string $id): mixed
8282
* Pre-registered params bypass the container entirely — useful in tests to supply controlled values.
8383
*
8484
* @param string $executionId Execution identifier matching the one passed to {@see call()}.
85-
* @param array $params Parameters spread into the callback as positional arguments.
85+
* @param array $params Parameters spread into the callback as positional arguments.
8686
*/
8787
public function setCallParams(string $executionId, array $params): self
8888
{
@@ -97,9 +97,9 @@ public function setCallParams(string $executionId, array $params): self
9797
* 1. Pre-registered params for the given execution ID (see {@see setCallParams()}) — spread as positional args.
9898
* 2. The injected container (see {@see setContainer()}) — resolved via {@see Container::call()}.
9999
*
100-
* @param string|array $executionId Callback identifier; arrays are joined with '.' so callers can build
100+
* @param string|array $executionId Callback identifier; arrays are joined with '.' so callers can build
101101
* dot-paths by passing segments (e.g. ['scope', 'apply', $key]).
102-
* @param array|null $parameters Named parameters forwarded to {@see Container::call()} when falling back
102+
* @param array|null $parameters Named parameters forwarded to {@see Container::call()} when falling back
103103
* to the container. Has no effect when pre-registered params are present.
104104
* @throws ServiceLocatorException when no pre-registered params and no container are available.
105105
*/

0 commit comments

Comments
 (0)