assertNotNull($sheet); $parsed = TrackScoringSheet::parseAndValidateConfig($sheet); $this->assertTrue($parsed['ok']); $this->assertSame(100.0, $parsed['sheet']['full_score']); $this->assertCount(8, $parsed['sheet']['items']); } public function test_config_rejects_sum_not_100(): void { $parsed = TrackScoringSheet::parseAndValidateConfig([ 'version' => 1, 'title' => 't', 'items' => [ [ 'key' => 'a', 'sort' => 1, 'category' => '通用指标', 'title' => 'A', 'criteria' => '', 'max_score' => 40, ], ], ]); $this->assertFalse($parsed['ok']); $this->assertStringContainsString('100', $parsed['message']); } public function test_submit_requires_every_item_and_allows_zero(): void { $sheet = DefaultTrackScoringSheets::forTrackCode('xiaofei_ai', '消费+人工智能'); $this->assertNotNull($sheet); $parsed = TrackScoringSheet::parseAndValidateConfig($sheet); $this->assertTrue($parsed['ok']); $scores = []; foreach ($parsed['sheet']['items'] as $item) { $scores[$item['key']] = 0; } $ok = TrackScoringSheet::normalizeSubmitPayload($parsed['sheet'], ['scores' => $scores]); $this->assertTrue($ok['ok']); $this->assertSame(0.0, $ok['line_total']); unset($scores['market_prospect']); $missing = TrackScoringSheet::normalizeSubmitPayload($parsed['sheet'], ['scores' => $scores]); $this->assertFalse($missing['ok']); $this->assertStringContainsString('请填写', $missing['message']); } public function test_submit_rejects_over_max(): void { $sheet = DefaultTrackScoringSheets::forTrackCode('xiaofei_ai', '消费+人工智能'); $parsed = TrackScoringSheet::parseAndValidateConfig($sheet); $this->assertTrue($parsed['ok']); $scores = []; foreach ($parsed['sheet']['items'] as $item) { $scores[$item['key']] = 0; } $scores['market_prospect'] = 21; $over = TrackScoringSheet::normalizeSubmitPayload($parsed['sheet'], ['scores' => $scores]); $this->assertFalse($over['ok']); $this->assertStringContainsString('不得超过', $over['message']); } }