<commit_before><?php

namespace LotGD\Crate\GraphQL\Tests;

use DateInterval;

use LotGD\Crate\GraphQL\Tests\WebTestCase;

use LotGD\Crate\GraphQL\Models\ApiKey;
use LotGD\Crate\GraphQL\Models\User;

class ApiKeyTest extends WebTestCase
{
    public function testApiKeyGeneration()
    {
        $em = $this->getEntityManager();
        $user = $em->getRepository(User::class)->find(1);
        
        $this->assertFalse($user->hasApiKey());
        
        $key = ApiKey::generate($user, 10);
        $user->setApiKey($key);
        
        $this->assertTrue($user->hasApiKey());
        $this->assertTrue($key->isValid());
        
        $created = $key->getCreatedAt();
        $expires = $key->getExpiresAt();
        
        $created2 = $created->add(DateInterval::createFromDateString("10 seconds"));
        
        $this->assertEquals(
            $created2,
            $expires
        );
        
        $em->clear();
    }
}<commit_msg>Changed datetime comparison check in ApiKeyTest to ignore microtime.<commit_after><?php

namespace LotGD\Crate\GraphQL\Tests;

use DateInterval;

use LotGD\Crate\GraphQL\Tests\WebTestCase;

use LotGD\Crate\GraphQL\Models\ApiKey;
use LotGD\Crate\GraphQL\Models\User;

class ApiKeyTest extends WebTestCase
{
    public function testApiKeyGeneration()
    {
        $em = $this->getEntityManager();
        $user = $em->getRepository(User::class)->find(1);
        
        $this->assertFalse($user->hasApiKey());
        
        $key = ApiKey::generate($user, 10);
        $user->setApiKey($key);
        
        $this->assertTrue($user->hasApiKey());
        $this->assertTrue($key->isValid());
        
        $created = $key->getCreatedAt();
        $expires = $key->getExpiresAt();
        
        $created2 = $created->add(DateInterval::createFromDateString("10 seconds"));
        
        $this->assertEquals(
            $created2->format("Ymd-His"),
            $expires->format("Ymd-His")
        );
        
        $em->clear();
    }
}
{'fraction_non_alphanumeric': 0.15396113602391628, 'fraction_numerical': 0.006975585450921774, 'mean_word_length': 2.4033898305084747, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '6617357', 'n_tokens_mistral': 613, 'n_tokens_neox': 618, 'n_words': 88}