mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 15:42:48 +08:00
修复Request Test中isAjax和isPjax错误的测试用例
This commit is contained in:
@@ -34,11 +34,11 @@ trait ConfigInitTrait
|
|||||||
{
|
{
|
||||||
self::$internalConfigFoo = \Closure::bind(function($value = null) {
|
self::$internalConfigFoo = \Closure::bind(function($value = null) {
|
||||||
return !is_null($value) ? Config::$config = $value : Config::$config;
|
return !is_null($value) ? Config::$config = $value : Config::$config;
|
||||||
}, null, Config::class);
|
}, null, '\\Think\\Config');
|
||||||
|
|
||||||
self::$internalRangeFoo = \Closure::bind(function($value = null) {
|
self::$internalRangeFoo = \Closure::bind(function($value = null) {
|
||||||
return !is_null($value) ? Config::$range = $value : Config::$range;
|
return !is_null($value) ? Config::$range = $value : Config::$range;
|
||||||
}, null, Config::class);
|
}, null, '\\Think\\Config');
|
||||||
|
|
||||||
self::$originConfig = call_user_func(self::$internalConfigFoo);
|
self::$originConfig = call_user_func(self::$internalConfigFoo);
|
||||||
self::$originRange = call_user_func(self::$internalRangeFoo);
|
self::$originRange = call_user_func(self::$internalRangeFoo);
|
||||||
|
|||||||
@@ -157,15 +157,31 @@ class requestTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testIsAjax()
|
public function testIsAjax()
|
||||||
{
|
{
|
||||||
$request = Request::create('');
|
$request = Request::create('');
|
||||||
|
|
||||||
|
$this->assertFalse($request->isAjax());
|
||||||
|
|
||||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest';
|
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest';
|
||||||
|
$this->assertFalse($request->isAjax());
|
||||||
|
$this->assertFalse($request->isAjax(true));
|
||||||
|
|
||||||
|
$request->server(['HTTP_X_REQUESTED_WITH' => 'xmlhttprequest']);
|
||||||
$this->assertTrue($request->isAjax());
|
$this->assertTrue($request->isAjax());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsPjax()
|
public function testIsPjax()
|
||||||
{
|
{
|
||||||
$request = Request::create('');
|
$request = Request::create('');
|
||||||
|
|
||||||
|
$this->assertFalse($request->isPjax());
|
||||||
|
|
||||||
$_SERVER['HTTP_X_PJAX'] = true;
|
$_SERVER['HTTP_X_PJAX'] = true;
|
||||||
|
$this->assertFalse($request->isPjax());
|
||||||
|
$this->assertFalse($request->isPjax(true));
|
||||||
|
|
||||||
|
$request->server(['HTTP_X_PJAX' => true]);
|
||||||
|
$this->assertTrue($request->isPjax());
|
||||||
|
$request->server(['HTTP_X_PJAX' => false]);
|
||||||
$this->assertTrue($request->isPjax());
|
$this->assertTrue($request->isPjax());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user