- 添加路由注解基础类 Get、Post、Put、Delete - 实现路由前缀和版本控制注解 Prefix、Version - 添加中间件和路由名称注解 Middleware、Name - 创建路由服务提供者 RouteServiceProvider - 实现控制器目录扫描和路由自动注册 - 添加配置文件支持控制器目录自定义 - 完善单元测试和集成测试用例 - 添加测试控制器和相关测试代码 - 配置 composer 自动加载和 laravel 服务提供者 - 添加 phpunit 测试配置和基础测试用例
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Jltx\Routes\Tests\Integration;
|
|
|
|
use Jltx\Routes\Tests\Fixtures\Controllers\TestController;
|
|
use Jltx\Routes\Tests\TestCase;
|
|
use ReflectionClass;
|
|
|
|
class RouteScanningTest extends TestCase
|
|
{
|
|
/** @test */
|
|
public function it_can_scan_directory_and_find_controllers()
|
|
{
|
|
// 测试目录扫描功能
|
|
$this->assertTrue(class_exists(TestController::class));
|
|
|
|
$reflection = new ReflectionClass(TestController::class);
|
|
$this->assertTrue($reflection->isUserDefined());
|
|
}
|
|
|
|
/** @test */
|
|
public function it_can_read_config_values()
|
|
{
|
|
// 测试配置读取功能
|
|
// 因为这是一个包环境,我们不能直接访问 Laravel 的 config() 函数
|
|
// 但我们可以通过检查配置文件的内容来验证结构
|
|
|
|
$config = include __DIR__.'/../../config/routes.php';
|
|
|
|
$this->assertArrayHasKey('controller_directories', $config);
|
|
$this->assertIsArray($config['controller_directories']);
|
|
|
|
// 注意:由于 app_path() 是 Laravel 辅助函数,在包测试环境中不可用
|
|
// 我们只需验证配置结构即可
|
|
}
|
|
}
|