Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
80.00% |
4 / 5 |
|
80.00% |
4 / 5 |
CRAP | |
0.00% |
0 / 1 |
| ExtensionTestingReport | |
80.00% |
4 / 5 |
|
80.00% |
4 / 5 |
5.20 | |
0.00% |
0 / 1 |
| newFactory | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| scopeByArtifact | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| scopeByEnvironment | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| scopeByStatus | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| scopeByUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Models; |
| 4 | |
| 5 | use Database\Factories\Http\Models\ExtensionTestingReportFactory; |
| 6 | use Illuminate\Database\Eloquent\Builder; |
| 7 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 8 | |
| 9 | /** |
| 10 | * Extension Testing Report Model |
| 11 | * |
| 12 | * Stores QA testing reports for FlyMSG extension artifacts (production and staging). |
| 13 | * Each user creates one report per artifact; others' reports are read-only to them. |
| 14 | * |
| 15 | * @property string $_id MongoDB ObjectId |
| 16 | * @property string $name Human-readable report name |
| 17 | * @property string $version_tested The extension version being tested (e.g., '1.2.3') |
| 18 | * @property string $environment The environment tested: 'staging' or 'production' |
| 19 | * @property string $artifact_id The artifact identifier linking to a production release or staging artifact |
| 20 | * @property string $tester_name The name of the person running the tests |
| 21 | * @property string $created_by The user ID of the report creator |
| 22 | * @property string $status Report status: 'in_progress' or 'completed' |
| 23 | * @property array $domains Nested array of DomainEntry objects with test areas and results |
| 24 | * @property \Carbon\Carbon $created_at |
| 25 | * @property \Carbon\Carbon $updated_at |
| 26 | */ |
| 27 | class ExtensionTestingReport extends Moloquent |
| 28 | { |
| 29 | use HasFactory; |
| 30 | |
| 31 | /** |
| 32 | * Create a new factory instance for the model. |
| 33 | */ |
| 34 | protected static function newFactory(): ExtensionTestingReportFactory |
| 35 | { |
| 36 | return ExtensionTestingReportFactory::new(); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * The connection name for the model. |
| 41 | * |
| 42 | * @var string |
| 43 | */ |
| 44 | protected $connection = 'mongodb'; |
| 45 | |
| 46 | /** |
| 47 | * The collection associated with the model. |
| 48 | * |
| 49 | * @var string |
| 50 | */ |
| 51 | protected $table = 'extension_testing_reports'; |
| 52 | |
| 53 | /** |
| 54 | * The attributes that are mass assignable. |
| 55 | * |
| 56 | * @var array<int, string> |
| 57 | */ |
| 58 | protected $fillable = [ |
| 59 | 'name', |
| 60 | 'version_tested', |
| 61 | 'environment', |
| 62 | 'artifact_id', |
| 63 | 'tester_name', |
| 64 | 'created_by', |
| 65 | 'status', |
| 66 | 'domains', |
| 67 | ]; |
| 68 | |
| 69 | /** |
| 70 | * The attributes that should be cast. |
| 71 | * |
| 72 | * @var array<string, string> |
| 73 | */ |
| 74 | protected $casts = [ |
| 75 | 'domains' => 'array', |
| 76 | 'created_at' => 'datetime', |
| 77 | 'updated_at' => 'datetime', |
| 78 | ]; |
| 79 | |
| 80 | /** |
| 81 | * Report status constants. |
| 82 | */ |
| 83 | public const STATUS_IN_PROGRESS = 'in_progress'; |
| 84 | |
| 85 | public const STATUS_COMPLETED = 'completed'; |
| 86 | |
| 87 | /** |
| 88 | * Environment constants. |
| 89 | */ |
| 90 | public const ENV_STAGING = 'staging'; |
| 91 | |
| 92 | public const ENV_PRODUCTION = 'production'; |
| 93 | |
| 94 | /** |
| 95 | * Scope to filter by artifact ID. |
| 96 | * |
| 97 | * @param string $artifactId The artifact identifier |
| 98 | */ |
| 99 | public function scopeByArtifact(Builder $query, string $artifactId): Builder |
| 100 | { |
| 101 | return $query->where('artifact_id', $artifactId); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Scope to filter by environment. |
| 106 | * |
| 107 | * @param string $environment 'staging' or 'production' |
| 108 | */ |
| 109 | public function scopeByEnvironment(Builder $query, string $environment): Builder |
| 110 | { |
| 111 | return $query->where('environment', $environment); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Scope to filter by status. |
| 116 | * |
| 117 | * @param string $status 'in_progress' or 'completed' |
| 118 | */ |
| 119 | public function scopeByStatus(Builder $query, string $status): Builder |
| 120 | { |
| 121 | return $query->where('status', $status); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Scope to filter by report creator. |
| 126 | * |
| 127 | * @param string $userId The user ID |
| 128 | */ |
| 129 | public function scopeByUser(Builder $query, string $userId): Builder |
| 130 | { |
| 131 | return $query->where('created_by', $userId); |
| 132 | } |
| 133 | } |