mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-12 01:54:26 +02:00
Add feedback - avoid intermediate variables
This commit is contained in:
parent
adf0d7bc95
commit
301ac83ebf
42 changed files with 367 additions and 272 deletions
|
@ -34,7 +34,8 @@ class SearchTest extends ApiTest
|
|||
{
|
||||
$directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))->run();
|
||||
$response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -51,8 +52,10 @@ class SearchTest extends ApiTest
|
|||
|
||||
$directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$search = new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $search->run(['searchstring' => 'item_body']);
|
||||
$response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'searchstring' => 'item_body'
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -70,8 +73,10 @@ class SearchTest extends ApiTest
|
|||
{
|
||||
$directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$search = new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $search->run(['searchstring' => 'test']);
|
||||
$response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'searchstring' => 'test'
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -66,17 +66,20 @@ class NotificationTest extends ApiTest
|
|||
</notes>
|
||||
XML;
|
||||
|
||||
$notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']);
|
||||
$response = $notification->run();
|
||||
$response = (new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']))
|
||||
->run();
|
||||
|
||||
self::assertXmlStringEqualsXmlString($assertXml, (string)$response->getBody());
|
||||
self::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders());
|
||||
self::assertEquals([
|
||||
'Content-type' => ['text/xml'],
|
||||
ICanCreateResponses::X_HEADER => ['xml']
|
||||
], $response->getHeaders());
|
||||
}
|
||||
|
||||
public function testWithJsonResult()
|
||||
{
|
||||
$notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']);
|
||||
$response = $notification->run();
|
||||
$response = (new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -88,6 +91,9 @@ XML;
|
|||
self::assertIsString($note->msg);
|
||||
}
|
||||
|
||||
self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
self::assertEquals([
|
||||
'Content-type' => ['application/json'],
|
||||
ICanCreateResponses::X_HEADER => ['json']
|
||||
], $response->getHeaders());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,10 @@ class DeleteTest extends ApiTest
|
|||
{
|
||||
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
|
||||
|
||||
$delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $delete->run(['photo_id' => '709057080661a283a6aa598501504178']);
|
||||
$response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'photo_id' => '709057080661a283a6aa598501504178'
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -63,8 +65,10 @@ class DeleteTest extends ApiTest
|
|||
{
|
||||
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
|
||||
|
||||
$delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $delete->run(['photo_id' => '709057080661a283a6aa598501504178']);
|
||||
$response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'photo_id' => '709057080661a283a6aa598501504178'
|
||||
]);
|
||||
|
||||
$responseText = (string)$response->getBody();
|
||||
|
||||
|
|
|
@ -32,22 +32,28 @@ class DeleteTest extends ApiTest
|
|||
public function testEmpty()
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
(new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run();
|
||||
(new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run();
|
||||
|
||||
}
|
||||
|
||||
public function testWrong()
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
(new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['album' => 'album_name']);
|
||||
(new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'album' => 'album_name'
|
||||
]);
|
||||
}
|
||||
|
||||
public function testValidWithDelete()
|
||||
{
|
||||
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
|
||||
|
||||
$delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $delete->run(['album' => 'test_album']);
|
||||
$response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'album' => 'test_album']
|
||||
);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -32,19 +32,27 @@ class UpdateTest extends ApiTest
|
|||
public function testEmpty()
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run();
|
||||
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run();
|
||||
}
|
||||
|
||||
public function testTooFewArgs()
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['album' => 'album_name']);
|
||||
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'album' => 'album_name'
|
||||
]);
|
||||
}
|
||||
|
||||
public function testWrongUpdate()
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['album' => 'album_name', 'album_new' => 'album_name']);
|
||||
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'album' => 'album_name',
|
||||
'album_new' => 'album_name'
|
||||
]);
|
||||
}
|
||||
|
||||
public function testWithoutAuthenticatedUser()
|
||||
|
@ -56,7 +64,11 @@ class UpdateTest extends ApiTest
|
|||
{
|
||||
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
|
||||
|
||||
$response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['album' => 'test_album', 'album_new' => 'test_album_2']);
|
||||
$response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'album' => 'test_album',
|
||||
'album_new' => 'test_album_2'
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue