<commit_before><?php

/*
 * This file is part of Cachet.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CachetHQ\Tests\Cachet\Api;

use CachetHQ\Tests\Cachet\AbstractTestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;

class MetricTest extends AbstractTestCase
{
    use DatabaseMigrations;

    public function testGetMetrics()
    {
        $this->get('/api/v1/metrics')->seeJson(['data' => []]);
    }
}<commit_msg>Start working on metric tests<commit_after><?php

/*
 * This file is part of Cachet.
 *
 * (c) Cache<NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CachetHQ\Tests\Cachet\Api;

use CachetHQ\Tests\Cachet\AbstractTestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;

class MetricTest extends AbstractTestCase
{
    use DatabaseMigrations;

    public function testGetMetrics()
    {
        $this->get('/api/v1/metrics')->seeJson(['data' => []]);
    }

    public function testGetInvalidMetric()
    {
        $this->get('/api/v1/metrics/1');
        $this->assertResponseStatus(404);
    }

    public function testPostMetricUnauthorized()
    {
        $this->post('/api/v1/metrics');
        $this->assertResponseStatus(401);
    }

    public function testPostMetricNoData()
    {
        $this->beUser();

        $this->post('/api/v1/metrics');
        $this->assertResponseStatus(400);
    }

    public function testPostMetric()
    {
        $this->beUser();

        $this->post('/api/v1/metrics', [
            'name'          => 'Foo',
            'suffix'        => 'foo\'s per second',
            'description'   => 'Lorem ipsum dolor',
            'default_value' => 1,
            'display_chart' => 1,
        ]);
        $this->seeJson(['name' => 'Foo']);
    }
}
{'fraction_non_alphanumeric': 0.1413265306122449, 'fraction_numerical': 0.009183673469387756, 'mean_word_length': 2.7281368821292777, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '86086', 'n_tokens_mistral': 602, 'n_tokens_neox': 586, 'n_words': 131}