| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace Tests\Unit\ThirdParty;
- use PHPUnit\Framework\TestSuite;
- /**
- * ThirdParty模块测试套件
- *
- * 组织ThirdParty模块的所有测试用例
- * 提供统一的测试入口点
- */
- class ThirdPartyTestSuite
- {
- /**
- * 创建测试套件
- */
- public static function suite(): TestSuite
- {
- $suite = new TestSuite('ThirdParty模块测试套件');
-
- // 添加基础架构测试
- $suite->addTestSuite(BaseRequestTest::class);
-
- // 添加URS Request机制测试
- $suite->addTestSuite(UrsRequestTest::class);
-
- // 添加URS加密服务测试
- $suite->addTestSuite(UrsCryptoServiceTest::class);
-
- return $suite;
- }
-
- /**
- * 获取测试统计信息
- */
- public static function getTestStats(): array
- {
- $testClasses = [
- BaseRequestTest::class,
- UrsRequestTest::class,
- UrsCryptoServiceTest::class,
- ];
-
- $totalTests = 0;
- $testsByClass = [];
-
- foreach ($testClasses as $className) {
- $reflection = new \ReflectionClass($className);
- $methods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
-
- $testMethods = array_filter($methods, function($method) {
- return strpos($method->getName(), 'test') === 0;
- });
-
- $count = count($testMethods);
- $totalTests += $count;
- $testsByClass[$className] = $count;
- }
-
- return [
- 'total_tests' => $totalTests,
- 'test_classes' => count($testClasses),
- 'tests_by_class' => $testsByClass,
- ];
- }
-
- /**
- * 打印测试统计信息
- */
- public static function printTestStats(): void
- {
- $stats = self::getTestStats();
-
- echo "\n=== ThirdParty模块测试统计 ===\n";
- echo "测试类数量: {$stats['test_classes']}\n";
- echo "测试方法总数: {$stats['total_tests']}\n";
- echo "\n各类测试分布:\n";
-
- foreach ($stats['tests_by_class'] as $className => $count) {
- $shortName = substr($className, strrpos($className, '\\') + 1);
- echo " {$shortName}: {$count}个测试\n";
- }
-
- echo "\n运行命令:\n";
- echo " vendor/bin/phpunit tests/Unit/ThirdParty/\n";
- echo " vendor/bin/phpunit tests/Unit/ThirdParty/UrsRequestTest.php\n";
- echo " vendor/bin/phpunit tests/Unit/ThirdParty/BaseRequestTest.php\n";
- echo " vendor/bin/phpunit tests/Unit/ThirdParty/UrsCryptoServiceTest.php\n";
- echo "\n";
- }
- }
|