vendor/topthink/framework/tests/RouteTest.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace think\tests;
use Closure;
use Mockery as m;
use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
use think\helper\Str;
use think\Request;
use think\response\Redirect;
use think\response\View;
use think\Route;
class RouteTest extends TestCase
{
use InteractsWithApp;
/** @var Route|MockInterface */
protected $route;
protected function tearDown(): void
{
m::close();
}
protected function setUp()
{
$this->prepareApp();
$this->route = new Route($this->app);
}
/**
* @param $path
* @param string $method
* @param string $host
* @return m\Mock|Request
*/
protected function makeRequest($path, $method = 'GET', $host = 'localhost')
{
$request = m::mock(Request::class)->makePartial();
$request->shouldReceive('host')->andReturn($host);
$request->shouldReceive('pathinfo')->andReturn($path);
$request->shouldReceive('url')->andReturn('/' . $path);
$request->shouldReceive('method')->andReturn(strtoupper($method));
return $request;
}
public function testSimpleRequest()
{
$this->route->get('foo', function () {
return 'get-foo';
});
$this->route->put('foo', function () {
return 'put-foo';
});
$this->route->group(function () {
$this->route->post('foo', function () {
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。