<commit_before><?php

use Northstar\Models\Client;

class HelpersTest extends TestCase
{
    /** @test */
    public function testRouteHasAttachedMiddleware()
    {
        $this->get('/login');

        // It should be able to check if in a middleware group.
        $this->assertTrue(has_middleware('web'));
        $this->assertFalse(has_middleware('api'));

        // ...or just if it has any middleware at all!
        $this->assertTrue(has_middleware());
    }

    /** @test */
    public function testGetClientId()
    {
        // Web requests should report as 'northstar'.
        $this->get('/register');
        $this->assertEquals(client_id(), 'northstar');

        // Make a request using legacy API header.
        $client = Client::create(['client_id' => 'legacy_client', 'scope' => 'user']);
        $this->withLegacyApiKey($client)->json('POST', '/v1/auth/register', [
            'email' => $this->faker->safeEmail,
            'password' => $<PASSWORD>,<commit_msg>Add unit tests for format_date helper.<commit_after><?php

use Carbon\Carbon;
use Northstar\Models\Client;

class HelpersTest extends TestCase
{
    /** @test */
    public function testFormatDate()
    {
        // It should format strings that PHP can parse as DateTimes.
        $this->assertEquals(format_date('10/25/1990'), 'Oct 25, 1990');
        $this->assertEquals(format_date('1990-10-25'), 'Oct 25, 1990');

        // It should also format Carbon objects.
        $carbonDate = Carbon::create(1990, 10, 25);
        $this->assertEquals(format_date($carbonDate), 'Oct 25, 1990');

        // It should return null if null is passed.
        $this->assertEquals(format_date(null), null);
    }

    /** @test */
    public function testRouteHasAttachedMiddleware()
    {
        $this->get('/login');

        // It should be able to check if in a middleware group.
        $this->assertTrue(has_middleware('web'));
        $this->assertFalse(has_middleware('api'));

        // ...or just if it has any middleware at all!
        $this->assertTrue(has_middleware());
    }

    /** @test */
    public function testGetClientId()
    {
        // Web requests should report as 'northstar'.
        $this->get('/register');
        $this->assertEquals(client_id(), 'northstar');

        // Make a request using legacy API header.
        $client = Client::create(['client_id' => 'legacy_client', 'scope' => 'user']);
        $this->withLegacyApiKey($client)->json('POST', '/v1/auth/register', [
            'email' => $this->faker->safeEmail,
            'password' => $this->faker->password,
{'fraction_non_alphanumeric': 0.15797605252993432, 'fraction_numerical': 0.016994978756276556, 'mean_word_length': 2.6376404494382024, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '772750', 'n_tokens_mistral': 783, 'n_tokens_neox': 734, 'n_words': 184}