vendor/topthink/framework/tests/MiddlewareTest.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace think\tests;
use Mockery as m;
use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
use think\Exception;
use think\exception\Handle;
use think\Middleware;
use think\Pipeline;
use think\Request;
use think\Response;
class MiddlewareTest extends TestCase
{
use InteractsWithApp;
/** @var Middleware|MockInterface */
protected $middleware;
protected function tearDown(): void
{
m::close();
}
protected function setUp()
{
$this->prepareApp();
$this->middleware = new Middleware($this->app);
}
public function testSetMiddleware()
{
$this->middleware->add('BarMiddleware', 'bar');
$this->assertEquals(1, count($this->middleware->all('bar')));
$this->middleware->controller('BarMiddleware');
$this->assertEquals(1, count($this->middleware->all('controller')));
$this->middleware->import(['FooMiddleware']);
$this->assertEquals(1, count($this->middleware->all()));
$this->middleware->unshift(['BazMiddleware', 'baz']);
$this->assertEquals(2, count($this->middleware->all()));
$this->assertEquals([['BazMiddleware', 'handle'], 'baz'], $this->middleware->all()[0]);
$this->config->shouldReceive('get')->with('middleware.alias', [])->andReturn(['foo' => ['FooMiddleware', 'FarMiddleware']]);
$this->middleware->add('foo');
$this->assertEquals(3, count($this->middleware->all()));
$this->middleware->add(function () {
});
$this->middleware->add(function () {
});
$this->assertEquals(5, count($this->middleware->all()));
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。