1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-08 06:06:45 +02:00

feat(tests): update tests for endpoints #477

This commit is contained in:
Awilum
2020-11-22 17:44:56 +03:00
parent 5065703d80
commit 3fe5c7f0e9
3 changed files with 16 additions and 4 deletions

View File

@@ -42,6 +42,7 @@ jobs:
- .git*/**
- vendor/**
- var/**
- tests/**
- .github/**
- name: Run Tests

View File

@@ -53,7 +53,7 @@ flextype()->get('/api/registry', function (Request $request, Response $response)
$registry_token_file_path = PATH['project'] . '/tokens/registry/' . $token . '/token.yaml';
// Set token file
if ($registry_token_file_data = flextype('yaml')->decode(Filesystem::read($registry_token_file_path))) {
if ($registry_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($registry_token_file_path)->get())) {
if ($registry_token_file_data['state'] === 'disabled' ||
($registry_token_file_data['limit_calls'] !== 0 && $registry_token_file_data['calls'] >= $registry_token_file_data['limit_calls'])) {
return $response->withStatus($api_errors['0003']['http_status_code'])
@@ -74,7 +74,9 @@ flextype()->get('/api/registry', function (Request $request, Response $response)
}
// Update calls counter
Filesystem::write($registry_token_file_path, flextype('yaml')->encode(array_replace_recursive($registry_token_file_data, ['calls' => $registry_token_file_data['calls'] + 1])));
flextype('filesystem')->file($registry_token_file_path)
->put(flextype('yaml')
->encode(array_replace_recursive($registry_token_file_data, ['calls' => $registry_token_file_data['calls'] + 1]));
if ($response_code === 404) {
// Return response

View File

@@ -4,6 +4,15 @@ declare(strict_types=1);
uses()->group('endpoints');
test('test /api/registry', function () {
$this->assertTrue(true);
beforeEach(function() {
$this->client = new GuzzleHttp\Client();
});
test('test /api/registry', function () {
$response = $this->client->request('GET', 'https://test.flextype.org/api/registry', [
'id' => 'flextype.manifest.version',
'token' => 'e15dbc9336c924e31a5b3b4e66f96351'
]);
$this->assertEquals('0.9.12', json_decode($response->getBody())['data']['key']);
});