wallabag/tests/Wallabag/ApiBundle/Controller/ConfigRestControllerTest.php

48 lines
1.7 KiB
PHP
Raw Normal View History

2022-03-15 09:18:28 +00:00
<?php
namespace Tests\Wallabag\ApiBundle\Controller;
use Tests\Wallabag\ApiBundle\WallabagApiTestCase;
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()
{
$client = static::createClient();
$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'));
}
}