Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ExtensionTestingReportResource
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 toArray
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Resources\v2;
4
5use Illuminate\Http\Request;
6use Illuminate\Http\Resources\Json\JsonResource;
7
8/**
9 * Extension Testing Report Resource
10 *
11 * Transforms an ExtensionTestingReport model for API responses.
12 * Maps MongoDB _id to id and returns all report fields.
13 *
14 * @property string $_id MongoDB ObjectId
15 * @property string $name Human-readable report name
16 * @property string $version_tested The extension version being tested
17 * @property string $environment The environment tested: 'staging' or 'production'
18 * @property string $artifact_id The artifact identifier
19 * @property string $tester_name The name of the person running the tests
20 * @property string $created_by The user ID of the report creator
21 * @property string $status Report status: 'in_progress' or 'completed'
22 * @property array|null $domains Nested array of DomainEntry objects
23 * @property \Carbon\Carbon $created_at
24 * @property \Carbon\Carbon $updated_at
25 */
26class ExtensionTestingReportResource extends JsonResource
27{
28    /**
29     * Transform the resource into an array.
30     *
31     * @return array{
32     *   id: string,
33     *   name: string,
34     *   version_tested: string,
35     *   environment: string,
36     *   artifact_id: string,
37     *   tester_name: string,
38     *   created_by: string,
39     *   status: string,
40     *   domains: array,
41     *   created_at: string,
42     *   updated_at: string
43     * }
44     */
45    public function toArray(Request $request): array
46    {
47        return [
48            'id' => (string) $this->_id,
49            'name' => $this->name,
50            'version_tested' => $this->version_tested,
51            'environment' => $this->environment,
52            'artifact_id' => $this->artifact_id,
53            'tester_name' => $this->tester_name,
54            'created_by' => $this->created_by,
55            'status' => $this->status,
56            'domains' => $this->domains ?? [],
57            'created_at' => $this->created_at,
58            'updated_at' => $this->updated_at,
59        ];
60    }
61}