mirror of
https://github.com/friendica/friendica
synced 2025-04-26 02:30:11 +00:00
Remove deprecated App::module - replace with DI::module()->getName()
This commit is contained in:
parent
33674808dc
commit
4835f1185f
8 changed files with 72 additions and 49 deletions
|
@ -115,8 +115,7 @@ class ApiTest extends DatabaseTest
|
|||
// User ID that we know is not in the database
|
||||
$this->wrongUserId = 666;
|
||||
|
||||
$session = DI::session();
|
||||
$session->start();
|
||||
DI::session()->start();
|
||||
|
||||
// Most API require login so we force the session
|
||||
$_SESSION = [
|
||||
|
@ -433,12 +432,14 @@ class ApiTest extends DatabaseTest
|
|||
}
|
||||
];
|
||||
$_SERVER['REQUEST_METHOD'] = 'method';
|
||||
$_SERVER['QUERY_STRING'] = 'q=api_path';
|
||||
$_GET['callback'] = 'callback_name';
|
||||
|
||||
$this->app->query_string = 'api_path';
|
||||
$args = DI::args()->determine($_SERVER, $_GET);
|
||||
|
||||
$this->assertEquals(
|
||||
'callback_name(["some_data"])',
|
||||
api_call($this->app)
|
||||
api_call($this->app, $args)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -457,7 +458,12 @@ class ApiTest extends DatabaseTest
|
|||
return ['data' => ['some_data']];
|
||||
}
|
||||
];
|
||||
|
||||
$_SERVER['REQUEST_METHOD'] = 'method';
|
||||
$_SERVER['QUERY_STRING'] = 'q=api_path';
|
||||
|
||||
$args = DI::args()->determine($_SERVER, $_GET);
|
||||
|
||||
$this->config->set('system', 'profiler', true);
|
||||
$this->config->set('rendertime', 'callstack', true);
|
||||
$this->app->callstack = [
|
||||
|
@ -468,10 +474,9 @@ class ApiTest extends DatabaseTest
|
|||
'network' => ['some_function' => 200]
|
||||
];
|
||||
|
||||
$this->app->query_string = 'api_path';
|
||||
$this->assertEquals(
|
||||
'["some_data"]',
|
||||
api_call($this->app)
|
||||
api_call($this->app, $args)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -491,11 +496,13 @@ class ApiTest extends DatabaseTest
|
|||
}
|
||||
];
|
||||
$_SERVER['REQUEST_METHOD'] = 'method';
|
||||
$_SERVER['QUERY_STRING'] = 'q=api_path';
|
||||
|
||||
$args = DI::args()->determine($_SERVER, $_GET);
|
||||
|
||||
$this->app->query_string = 'api_path';
|
||||
$this->assertEquals(
|
||||
'{"status":{"error":"Internal Server Error","code":"500 Internal Server Error","request":"api_path"}}',
|
||||
api_call($this->app)
|
||||
api_call($this->app, $args)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -529,11 +536,13 @@ class ApiTest extends DatabaseTest
|
|||
}
|
||||
];
|
||||
$_SERVER['REQUEST_METHOD'] = 'method';
|
||||
$_SERVER['QUERY_STRING'] = 'q=api_path.json';
|
||||
|
||||
$args = DI::args()->determine($_SERVER, $_GET);
|
||||
|
||||
$this->app->query_string = 'api_path.json';
|
||||
$this->assertEquals(
|
||||
'["some_data"]',
|
||||
api_call($this->app)
|
||||
api_call($this->app, $args)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -553,11 +562,13 @@ class ApiTest extends DatabaseTest
|
|||
}
|
||||
];
|
||||
$_SERVER['REQUEST_METHOD'] = 'method';
|
||||
$_SERVER['QUERY_STRING'] = 'q=api_path.xml';
|
||||
|
||||
$args = DI::args()->determine($_SERVER, $_GET);
|
||||
|
||||
$this->app->query_string = 'api_path.xml';
|
||||
$this->assertEquals(
|
||||
'some_data',
|
||||
api_call($this->app)
|
||||
api_call($this->app, $args)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -577,12 +588,14 @@ class ApiTest extends DatabaseTest
|
|||
}
|
||||
];
|
||||
$_SERVER['REQUEST_METHOD'] = 'method';
|
||||
$_SERVER['QUERY_STRING'] = 'q=api_path.rss';
|
||||
|
||||
$args = DI::args()->determine($_SERVER, $_GET);
|
||||
|
||||
$this->app->query_string = 'api_path.rss';
|
||||
$this->assertEquals(
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
|
||||
'some_data',
|
||||
api_call($this->app)
|
||||
api_call($this->app, $args)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -602,12 +615,14 @@ class ApiTest extends DatabaseTest
|
|||
}
|
||||
];
|
||||
$_SERVER['REQUEST_METHOD'] = 'method';
|
||||
$_SERVER['QUERY_STRING'] = 'q=api_path.atom';
|
||||
|
||||
$args = DI::args()->determine($_SERVER, $_GET);
|
||||
|
||||
$this->app->query_string = 'api_path.atom';
|
||||
$this->assertEquals(
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
|
||||
'some_data',
|
||||
api_call($this->app)
|
||||
api_call($this->app, $args)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -622,10 +637,13 @@ class ApiTest extends DatabaseTest
|
|||
global $API;
|
||||
$API['api_path'] = ['method' => 'method'];
|
||||
|
||||
$this->app->query_string = 'api_path';
|
||||
$_SERVER['QUERY_STRING'] = 'q=api_path';
|
||||
|
||||
$args = DI::args()->determine($_SERVER, $_GET);
|
||||
|
||||
$this->assertEquals(
|
||||
'{"status":{"error":"Method Not Allowed","code":"405 Method Not Allowed","request":"api_path"}}',
|
||||
api_call($this->app)
|
||||
api_call($this->app, $args)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -642,13 +660,15 @@ class ApiTest extends DatabaseTest
|
|||
'method' => 'method',
|
||||
'auth' => true
|
||||
];
|
||||
$_SERVER['REQUEST_METHOD'] = 'method';
|
||||
$_SESSION['authenticated'] = false;
|
||||
$_SERVER['REQUEST_METHOD'] = 'method';
|
||||
$_SERVER['QUERY_STRING'] = 'q=api_path';
|
||||
|
||||
$args = DI::args()->determine($_SERVER, $_GET);
|
||||
|
||||
$this->app->query_string = 'api_path';
|
||||
$this->assertEquals(
|
||||
'{"status":{"error":"This API requires login","code":"401 Unauthorized","request":"api_path"}}',
|
||||
api_call($this->app)
|
||||
api_call($this->app, $args)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -662,7 +682,7 @@ class ApiTest extends DatabaseTest
|
|||
{
|
||||
$this->assertEquals(
|
||||
'{"status":{"error":"error_message","code":"200 OK","request":""}}',
|
||||
api_error('json', new HTTPException\OKException('error_message'))
|
||||
api_error('json', new HTTPException\OKException('error_message'), DI::args())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -683,7 +703,7 @@ class ApiTest extends DatabaseTest
|
|||
' <code>200 OK</code>' . "\n" .
|
||||
' <request/>' . "\n" .
|
||||
'</status>' . "\n",
|
||||
api_error('xml', new HTTPException\OKException('error_message'))
|
||||
api_error('xml', new HTTPException\OKException('error_message'), DI::args())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -704,7 +724,7 @@ class ApiTest extends DatabaseTest
|
|||
' <code>200 OK</code>' . "\n" .
|
||||
' <request/>' . "\n" .
|
||||
'</status>' . "\n",
|
||||
api_error('rss', new HTTPException\OKException('error_message'))
|
||||
api_error('rss', new HTTPException\OKException('error_message'), DI::args())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -725,7 +745,7 @@ class ApiTest extends DatabaseTest
|
|||
' <code>200 OK</code>' . "\n" .
|
||||
' <request/>' . "\n" .
|
||||
'</status>' . "\n",
|
||||
api_error('atom', new HTTPException\OKException('error_message'))
|
||||
api_error('atom', new HTTPException\OKException('error_message'), DI::args())
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue