use Dice\Dice;
use Friendica\App;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IPConfiguration;
use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\Core\Session\ISession;
/** @var App */
protected $app;
- /** @var Configuration */
+ /** @var IConfiguration */
protected $config;
/** @var Dice */
/** @var Database $dba */
$dba = $this->dice->create(Database::class);
- /** @var Configuration $config */
- $this->config = $this->dice->create(Configuration::class);
+ /** @var IConfiguration $config */
+ $this->config = $this->dice->create(IConfiguration::class);
$this->config->set('system', 'url', 'http://localhost');
$this->config->set('system', 'hostname', 'localhost');
// 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 = [
}
];
$_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)
);
}
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 = [
'network' => ['some_function' => 200]
];
- $this->app->query_string = 'api_path';
$this->assertEquals(
'["some_data"]',
- api_call($this->app)
+ api_call($this->app, $args)
);
}
}
];
$_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)
);
}
}
];
$_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)
);
}
}
];
$_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)
);
}
}
];
$_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)
);
}
}
];
$_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)
);
}
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)
);
}
'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)
);
}
{
$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())
);
}
' <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())
);
}
' <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())
);
}
' <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())
);
}
*/
public function testApiGetUserWithFrioSchema()
{
- $pConfig = $this->dice->create(PConfiguration::class);
+ $pConfig = $this->dice->create(IPConfiguration::class);
$pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
$user = api_get_user($this->app);
$this->assertSelfUser($user);
*/
public function testApiGetUserWithCustomFrioSchema()
{
- $pConfig = $this->dice->create(PConfiguration::class);
+ $pConfig = $this->dice->create(IPConfiguration::class);
$pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
$pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
$pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
*/
public function testApiGetUserWithEmptyFrioSchema()
{
- $pConfig = $this->dice->create(PConfiguration::class);
+ $pConfig = $this->dice->create(IPConfiguration::class);
$pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
$user = api_get_user($this->app);
$this->assertSelfUser($user);
public function testApiFormatItemsEmbededImages()
{
$this->assertEquals(
- 'text ' . System::baseUrl() . '/display/item_guid',
+ 'text ' . DI::baseUrl() . '/display/item_guid',
api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
);
}
$result = api_statusnet_config('json');
$this->assertEquals('localhost', $result['config']['site']['server']);
$this->assertEquals('default', $result['config']['site']['theme']);
- $this->assertEquals(System::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
+ $this->assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
$this->assertTrue($result['config']['site']['fancy']);
$this->assertEquals('en', $result['config']['site']['language']);
$this->assertEquals('UTC', $result['config']['site']['timezone']);