refactor: extract frontpage to template (#3130)

Also introduce usage of Response object
This commit is contained in:
Dag 2022-11-07 18:22:54 +01:00 committed by GitHub
parent fe59cbabc9
commit 2ef98b299f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 147 additions and 225 deletions

View file

@ -2,36 +2,26 @@
namespace RssBridge\Tests\Actions;
use ActionFactory;
use BridgeFactory;
use PHPUnit\Framework\TestCase;
class ListActionTest extends TestCase
{
private $data;
/**
* @runInSeparateProcess
* @requires function xdebug_get_headers
*/
public function testHeaders()
{
$this->initAction();
$this->assertContains(
'Content-Type: application/json',
xdebug_get_headers()
);
$action = new \ListAction();
$response = $action->execute([]);
$headers = $response->getHeaders();
$this->assertSame($headers['Content-Type'], 'application/json');
}
/**
* @runInSeparateProcess
*/
public function testOutput()
{
$this->initAction();
$action = new \ListAction();
$response = $action->execute([]);
$data = $response->getBody();
$items = json_decode($this->data, true);
$items = json_decode($data, true);
$this->assertNotNull($items, 'invalid JSON output: ' . json_last_error_msg());
@ -77,17 +67,4 @@ class ListActionTest extends TestCase
$this->assertContains($bridge['status'], $allowedStatus, 'Invalid status value');
}
}
private function initAction()
{
$actionFactory = new ActionFactory();
$action = $actionFactory->create('list');
ob_start();
$action->execute([]);
$this->data = ob_get_contents();
ob_clean();
ob_end_flush();
}
}