wallabag/tests/Controller/Api/ConfigRestControllerTest.php

46 lines
1.6 KiB
PHP
Raw Normal View History

2022-03-15 09:18:28 +00:00
<?php
2024-02-19 00:30:12 +00:00
namespace Tests\Wallabag\Controller\Api;
2022-03-15 09:18:28 +00:00
class ConfigRestControllerTest extends WallabagApiTestCase
{
public function testGetConfig()
{
$this->client->request('GET', '/api/config.json');
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
2022-04-20 20:14:56 +00:00
$config = json_decode($this->client->getResponse()->getContent(), true);
2022-03-15 09:18:28 +00:00
2022-04-20 20:14:56 +00:00
$this->assertArrayHasKey('id', $config);
$this->assertArrayHasKey('items_per_page', $config);
$this->assertArrayHasKey('language', $config);
$this->assertArrayHasKey('reading_speed', $config);
$this->assertArrayHasKey('action_mark_as_read', $config);
$this->assertArrayHasKey('list_mode', $config);
2023-06-13 13:25:47 +00:00
$this->assertArrayHasKey('display_thumbnails', $config);
2022-03-15 09:18:28 +00:00
2022-04-20 20:14:56 +00:00
$this->assertSame(200.0, $config['reading_speed']);
$this->assertSame('en', $config['language']);
2023-06-13 13:25:47 +00:00
$this->assertCount(7, $config);
2022-03-15 09:18:28 +00:00
$this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
public function testGetConfigWithoutAuthentication()
{
2023-12-24 19:37:54 +00:00
$client = $this->createUnauthorizedClient();
2022-03-15 09:18:28 +00:00
$client->request('GET', '/api/config.json');
$this->assertSame(401, $client->getResponse()->getStatusCode());
2022-04-20 20:14:56 +00:00
$config = json_decode($client->getResponse()->getContent(), true);
2022-03-15 09:18:28 +00:00
2022-04-20 20:14:56 +00:00
$this->assertArrayHasKey('error', $config);
$this->assertArrayHasKey('error_description', $config);
2022-03-15 09:18:28 +00:00
2022-04-20 20:14:56 +00:00
$this->assertSame('access_denied', $config['error']);
2022-03-15 09:18:28 +00:00
$this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
}
}