<commit_before><?php

declare(strict_types=1);

namespace FlixTech\SchemaRegistryApi\Test\Model\Subject;

use FlixTech\SchemaRegistryApi\Model\Subject\Name;
use FlixTech\SchemaRegistryApi\Model\Subject\VersionId;
use FlixTech\SchemaRegistryApi\Test\ApiTestCase;
use GuzzleHttp\Psr7\Response;

class SubjectTest extends ApiTestCase
{
    /**
     * @test
     */
    public function it_should_return_all_SubjectNames(): array
    {
        $responses = [
            new Response(
                200,
                ['Content-Type' => 'application/vnd.schemaregistry.v1+json'],
                '["subject0", "subject1"]'
            )
        ];

        $api = $this->getApiWithMockResponses($responses);

        $subjects = $api->registeredSubjectNames();

        $this->assertCount(2, $subjects);

        /** @var \FlixTech\SchemaRegistryApi\Model\Subject\Name $subjectName */
        foreach ($subjects as $i => $subjectName) {
            $this->assertInstanceOf(Name::class, $subjectName);
            $this->assertEquals('subject' . $i, $subjectName->name());
        }

        return $this->requestContainer;
    }

    /**
     * @test
     *
     * @depends it_should_return_all_SubjectNames
     *
     * @param \GuzzleHttp\Psr7\Request[][] $requestContainer
     */
    public function it_should_call_the_correct_endpoints_for_SubjectNames_resource(array $requestContainer)
    {
        $this->assertMethodAndUri($requestContainer, 'GET', '/subjects');
    }

    /**
     * @test
     */
    public function it_should_return_single_Subject()
    {
        $api = $this->getApiWithMockResponses([]);

        $name = Name::create('subject');
        $subject = $api->subject($name);

        $this->assertTrue($subject->name()->equals($name));
    }

    /**
     * @test
     */
    public function it_should_find_all_VersionId()
    {
        $responses = [
            new Response(
                200,
                ['Content-Type' => 'application/vnd.schemaregistry.v1+json'],
                '[1, 2, 3]'
            )
        ];

        $api = $this->getApiWithMockResponses($responses);

        $name = Name::create('subject');
        $subject = $api->subject($name);

        $versions = $subject->versions();

        $this->assertCount(3, $versions);

        /** @var VersionId $versionId */
        foreach ($versions as $i => $versionId) {
            $this->assertInstanceOf(VersionId::class, $versionId);
            $this->assertEquals($i + 1, $versionId->value());
        }
    }

    /**
     * @test
     */
    public function it_should_get_a_specific_Version()
    {
        $responses = [
            new Response(
                200,
                ['Content-Type' => 'application/vnd.schemaregistry.v1+json'],
                '{"name": "test","version": 1,"schema": "{\"type\": \"string\"}"}'
            )
        ];

        $api = $this->getApiWithMockResponses($responses);
        $name = Name::create('test');
        $subject = $api->subject($name);

        $versionId = VersionId::create(1);
        $version = $subject->version($versionId);

        $this->assertTrue($version->id()->equals($versionId));
        $this->assertTrue($version->subjectName()->equals($name));
        $this->assertEquals('{"type": "string"}', $version->schema()->value());
    }
}<commit_msg>Added tests for correct endpoints in `SubjectTest`<commit_after><?php

declare(strict_types=1);

namespace FlixTech\SchemaRegistryApi\Test\Model\Subject;

use FlixTech\SchemaRegistryApi\Model\Subject\Name;
use FlixTech\SchemaRegistryApi\Model\Subject\VersionId;
use FlixTech\SchemaRegistryApi\Test\ApiTestCase;
use GuzzleHttp\Psr7\Response;

class SubjectTest extends ApiTestCase
{
    /**
     * @test
     */
    public function it_should_return_all_SubjectNames(): array
    {
        $responses = [
            new Response(
                200,
                ['Content-Type' => 'application/vnd.schemaregistry.v1+json'],
                '["subject0", "subject1"]'
            )
        ];

        $api = $this->getApiWithMockResponses($responses);

        $subjects = $api->registeredSubjectNames();

        $this->assertCount(2, $subjects);

        /** @var \FlixTech\SchemaRegistryApi\Model\Subject\Name $subjectName */
        foreach ($subjects as $i => $subjectName) {
            $this->assertInstanceOf(Name::class, $subjectName);
            $this->assertEquals('subject' . $i, $subjectName->name());
        }

        return $this->requestContainer;
    }

    /**
     * @test
     *
     * @depends it_should_return_all_SubjectNames
     *
     * @param \GuzzleHttp\Psr7\Request[][] $requestContainer
     */
    public function it_should_call_the_correct_endpoints_for_SubjectNames_resource(array $requestContainer)
    {
        $this->assertMethodAndUri($requestContainer, 'GET', '/subjects');
    }

    /**
     * @test
     */
    public function it_should_return_single_Subject()
    {
        $api = $this->getApiWithMockResponses([]);

        $name = Name::create('subject');
        $subject = $api->subject($name);

        $this->assertTrue($subject->name()->equals($name));
    }

    /**
     * @test
     */
    public function it_should_find_all_VersionId(): array
    {
        $responses = [
            new Response(
                200,
                ['Content-Type' => 'application/vnd.schemaregistry.v1+json'],
                '[1, 2, 3]'
            )
        ];

        $api = $this->getApiWithMockResponses($responses);

        $name = Name::create('subject');
        $subject = $api->subject($name);

        $versions = $subject->versions();

        $this->assertCount(3, $versions);

        /** @var VersionId $versionId */
        foreach ($versions as $i => $versionId) {
            $this->assertInstanceOf(VersionId::class, $versionId);
            $this->assertEquals($i + 1, $versionId->value());
        }

        return $this->requestContainer;
    }

    /**
     * @test
     *
     * @depends it_should_find_all_VersionId
     *
     * @param \GuzzleHttp\Psr7\Request[][] $requestContainer
     */
    public function it_should_call_the_correct_endpoints_for_Versions_resource(array $requestContainer)
    {
        $this->assertMethodAndUri($requestContainer, 'GET', '/subjects/subject/versions');
    }

    /**
     * @test
     */
    public function it_should_get_a_specific_Version(): array
    {
        $responses = [
            new Response(
                200,
                ['Content-Type' => 'application/vnd.schemaregistry.v1+json'],
                '{"name": "test","version": 1,"schema": "{\"type\": \"string\"}"}'
            )
        ];

        $api = $this->getApiWithMockResponses($responses);
        $name = Name::create('test');
        $subject = $api->subject($name);

        $versionId = VersionId::create(1);
        $version = $subject->version($versionId);

        $this->assertTrue($version->id()->equals($versionId));
        $this->assertTrue($version->subjectName()->equals($name));
        $this->assertEquals('{"type": "string"}', $version->schema()->value());

        return $this->requestContainer;
    }

    /**
     * @test
     *
     * @depends it_should_get_a_specific_Version
     *
     * @param \GuzzleHttp\Psr7\Request[][] $requestContainer
     */
    public function it_should_call_the_correct_endpoints_for_Version_resource(array $requestContainer)
    {
        $this->assertMethodAndUri($requestContainer, 'GET', '/subjects/test/versions/1');
    }
}
{'fraction_non_alphanumeric': 0.15453214428324238, 'fraction_numerical': 0.007054438972447757, 'mean_word_length': 2.3785971223021583, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 81, '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': '5982584', 'n_tokens_mistral': 2285, 'n_tokens_neox': 2194, 'n_words': 318}