mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-03 17:44:48 +02:00
refactor: extract frontpage to template (#3130)
Also introduce usage of Response object
This commit is contained in:
parent
fe59cbabc9
commit
2ef98b299f
12 changed files with 147 additions and 225 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue