/** * Test AJAX method detection with misspelled header */ public function testIsAjaxWithMisspelledHeader() { $env = Slim_Environment::mock(array('X_REQUESTED_WITH' => 'foo')); $req = new Slim_Http_Request($env); $this->assertFalse($req->isAjax()); $this->assertFalse($req->isXhr()); }
/** * Test AJAX method detection w/ query parameter */ public function testIsAjaxWithQueryParameter() { Slim_Environment::mock(array('REQUEST_METHOD' => 'HEAD', 'REMOTE_ADDR' => '127.0.0.1', 'SCRIPT_NAME' => '/foo/index.php', 'PATH_INFO' => '/bar/xyz', 'QUERY_STRING' => 'one=1&two=2&three=3&isajax=1', 'SERVER_NAME' => 'slim', 'SERVER_PORT' => 80, 'slim.url_scheme' => 'http', 'slim.input' => '', 'slim.errors' => fopen('php://stderr', 'w'), 'X_REQUESTED_WITH' => 'XMLHttpRequest')); $env = Slim_Environment::getInstance(); $req = new Slim_Http_Request($env); $this->assertTrue($req->isAjax()); $this->assertTrue($req->isXhr()); }