diff --git a/app/Models/Project.php b/app/Models/Project.php index 33ce72898c..91f97712cf 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -31,8 +31,8 @@ * @property bool $emailbrokensubmission * @property bool $emailredundantfailures * @property ?string $cvsviewertype - * @property int $testtimestd - * @property int $testtimestdthreshold + * @property float $testtimestd + * @property float $testtimestdthreshold * @property bool $showtesttime * @property int $testtimemaxstatus * @property int $emailmaxitems @@ -108,6 +108,33 @@ class Project extends Model 'coveragethreshold' => 'integer', 'showcoveragecode' => 'boolean', 'authenticatesubmissions' => 'boolean', + 'testtimestd' => 'float', + 'testtimestdthreshold' => 'float', + 'testtimemaxstatus' => 'integer', + 'emailmaxitems' => 'integer', + 'emailmaxchars' => 'integer', + 'autoremovetimeframe' => 'integer', + 'uploadquota' => 'integer', + ]; + + protected $attributes = [ + 'coveragethreshold' => 70, + 'nightlytime' => '00:00:00', + 'emaillowcoverage' => false, + 'emailtesttimingchanged' => false, + 'emailbrokensubmission' => true, + 'emailredundantfailures' => false, + 'testtimestd' => 4, + 'testtimestdthreshold' => 1, + 'showtesttime' => false, + 'testtimemaxstatus' => 3, + 'emailmaxitems' => 5, + 'emailmaxchars' => 255, + 'displaylabels' => true, + 'autoremovetimeframe' => 90, + 'uploadquota' => 10, + 'showcoveragecode' => true, + 'authenticatesubmissions' => false, ]; public const PROJECT_ADMIN = 2; diff --git a/app/cdash/tests/case/CDash/MultipleSubprojectsEmailTest.php b/app/cdash/tests/case/CDash/MultipleSubprojectsEmailTest.php index 54b3f1a314..d046b16fa3 100644 --- a/app/cdash/tests/case/CDash/MultipleSubprojectsEmailTest.php +++ b/app/cdash/tests/case/CDash/MultipleSubprojectsEmailTest.php @@ -32,9 +32,12 @@ use Illuminate\Support\Facades\URL; use Illuminate\Support\Str; use PHPUnit\Framework\MockObject\MockObject; +use Tests\Traits\CreatesProjects; class MultipleSubprojectsEmailTest extends CDashUseCaseTestCase { + use CreatesProjects; + private static $tz; private static $database; @@ -109,9 +112,8 @@ public function setUp(): void URL::forceRootUrl('http://open.cdash.org'); if (self::$projectid === -1) { - self::$projectid = DB::table('project')->insertGetId([ - 'name' => 'TestProject1', - ]); + $project = $this->makePublicProject('TestProject1'); + self::$projectid = $project->id; // A hack to make sure builds exist and can be referenced so we don't violate our foreign key constraints for ($i = 0; $i < 10; $i++) { diff --git a/app/cdash/tests/case/CDash/TestUseCaseTest.php b/app/cdash/tests/case/CDash/TestUseCaseTest.php index 1593d7ed9a..53ec32cad5 100644 --- a/app/cdash/tests/case/CDash/TestUseCaseTest.php +++ b/app/cdash/tests/case/CDash/TestUseCaseTest.php @@ -9,17 +9,19 @@ use CDash\Test\UseCase\UseCase; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; +use Tests\Traits\CreatesProjects; class TestUseCaseTest extends CDashUseCaseTestCase { + use CreatesProjects; + private int $projectid = -1; public function setUp(): void { $this->createApplication(); - $this->projectid = DB::table('project')->insertGetId([ - 'name' => 'TestProject1', - ]); + $project = $this->makePublicProject('TestProject1'); + $this->projectid = $project->id; // A hack to make sure builds exist and can be referenced so we don't violate our foreign key constraints for ($i = 0; $i < 10; $i++) { diff --git a/app/cdash/tests/test_buildmodel.php b/app/cdash/tests/test_buildmodel.php index f833f665c8..de1a551497 100644 --- a/app/cdash/tests/test_buildmodel.php +++ b/app/cdash/tests/test_buildmodel.php @@ -32,6 +32,7 @@ public function __construct() $project = Project::create([ 'name' => 'BuildModel', + 'public' => Project::ACCESS_PUBLIC, ]); DB::table('buildgroup')->insertOrIgnore([ diff --git a/database/migrations/2026_05_20_202347_project_defaults.php b/database/migrations/2026_05_20_202347_project_defaults.php new file mode 100644 index 0000000000..05021c6f51 --- /dev/null +++ b/database/migrations/2026_05_20_202347_project_defaults.php @@ -0,0 +1,33 @@ +toString(); - $this->projects[] = ProjectService::create([ - 'name' => $project_name, - ]); + $this->projects[] = $this->makePublicProject($project_name); $this->browse(function (Browser $browser) use ($project_name): void { $browser->loginAs($this->users['admin']) diff --git a/tests/Feature/AutoRemoveBuildsCommand.php b/tests/Feature/AutoRemoveBuildsCommand.php index e56b98e7d5..ab36796f29 100644 --- a/tests/Feature/AutoRemoveBuildsCommand.php +++ b/tests/Feature/AutoRemoveBuildsCommand.php @@ -3,16 +3,17 @@ namespace Tests\Feature; use App\Models\Project; -use App\Services\ProjectService; use CDash\Database; use CDash\Model\Build; use DateTime; use DateTimeZone; use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; +use Tests\Traits\CreatesProjects; class AutoRemoveBuildsCommand extends TestCase { + use CreatesProjects; use DatabaseTransactions; protected Project $project; @@ -21,10 +22,9 @@ public function setUp(): void { parent::setUp(); - $this->project = ProjectService::create([ - 'name' => 'AutoRemoveProject', - 'autoremovetimeframe' => 45, - ]); + $this->project = $this->makePublicProject('AutoRemoveProject'); + $this->project->autoremovetimeframe = 45; + $this->project->save(); } public function tearDown(): void diff --git a/tests/Feature/GraphQL/Mutations/UpdateProjectTest.php b/tests/Feature/GraphQL/Mutations/UpdateProjectTest.php index ff895d8140..282660c9ec 100644 --- a/tests/Feature/GraphQL/Mutations/UpdateProjectTest.php +++ b/tests/Feature/GraphQL/Mutations/UpdateProjectTest.php @@ -196,8 +196,8 @@ public static function fieldValues(): array ['emailTestTimingChanged', true, 'emailtesttimingchanged', true], ['emailBrokenSubmissions', true, 'emailbrokensubmission', true], ['emailRedundantFailures', true, 'emailredundantfailures', true], - ['testTimeStdMultiplier', 5.0, 'testtimestd', '5.00'], - ['testTimeStdThreshold', 2.0, 'testtimestdthreshold', '2.00'], + ['testTimeStdMultiplier', 5.0, 'testtimestd', 5.0], + ['testTimeStdThreshold', 2.0, 'testtimestdthreshold', 2.0], ['enableTestTiming', false, 'showtesttime', false], ['timeStatusFailureThreshold', 3, 'testtimemaxstatus', 3], ['emailMaxItems', 20, 'emailmaxitems', 20],