58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use Tests\TestCase;
|
|
|
|
class ApiV1EndpointsTest extends TestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
config()->set('dewemoji.data_path', base_path('tests/Fixtures/emojis.fixture.json'));
|
|
}
|
|
|
|
public function test_categories_endpoint_returns_category_map(): void
|
|
{
|
|
$response = $this->getJson('/v1/categories');
|
|
|
|
$response
|
|
->assertOk()
|
|
->assertHeader('X-Dewemoji-Tier', 'free')
|
|
->assertJsonPath('Smileys & Emotion.0', 'face-smiling')
|
|
->assertJsonPath('People & Body.0', 'hand-fingers-closed');
|
|
}
|
|
|
|
public function test_emojis_endpoint_supports_both_q_and_query_params(): void
|
|
{
|
|
$byQ = $this->getJson('/v1/emojis?q=grinning');
|
|
$byQuery = $this->getJson('/v1/emojis?query=grinning');
|
|
|
|
$byQ->assertOk()->assertJsonPath('total', 1);
|
|
$byQuery->assertOk()->assertJsonPath('total', 1);
|
|
$byQ->assertJsonPath('items.0.slug', 'grinning-face');
|
|
$byQuery->assertJsonPath('items.0.slug', 'grinning-face');
|
|
}
|
|
|
|
public function test_license_verify_returns_ok_when_accept_all_is_enabled(): void
|
|
{
|
|
config()->set('dewemoji.license.accept_all', true);
|
|
|
|
$response = $this->postJson('/v1/license/verify', [
|
|
'key' => 'dummy-key',
|
|
'account_id' => 'acct_123',
|
|
'version' => '1.0.0',
|
|
]);
|
|
|
|
$response
|
|
->assertOk()
|
|
->assertHeader('X-Dewemoji-Tier', 'pro')
|
|
->assertJson([
|
|
'ok' => true,
|
|
'tier' => 'pro',
|
|
]);
|
|
}
|
|
}
|
|
|