<commit_before><?php

declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\RecursionTest;

use Rebing\GraphQL\Tests\TestCase;
use Rebing\GraphQL\Tests\Unit\RecursionTest\Inputs\AuthorInput;
use Rebing\GraphQL\Tests\Unit\RecursionTest\Inputs\BookInput;
use Rebing\GraphQL\Tests\Unit\RecursionTest\Inputs\PublisherInput;
use Rebing\GraphQL\Tests\Unit\RecursionTest\Mutations\SaveAuthor;
use Rebing\GraphQL\Tests\Unit\RecursionTest\Mutations\SavePublisher;

class RecursionTest extends TestCase
{
    protected function getEnvironmentSetUp($app): void
    {
        parent::getEnvironmentSetUp($app);

        $app['config']->set('graphql.schemas.default', [
            'mutation' => [
                SaveAuthor::class,
                SavePublisher::class,
            ],
        ]);
        $app['config']->set('graphql.types', [
            AuthorInput::class,
            BookInput::class,
            PublisherInput::class,
        ]);
    }

    /**
     * @test
     */
    public function infiniteLoopDirectToOne(): void
    {
        $post = [
            'query' => 'mutation SaveAuthor($author: AuthorInput!) {
                SaveAuthor(author: $author)
            }',
            'variables' => [
                'author' => [
                    'name' => 'Some Author Name',
                    'bestSellingBook' => [
                        'name' => 'Book Name',
                    ],
                ],
            ],
            'operationName' => 'SaveAuthor',
        ];
        $response = $this->json('POST', '/graphql', $post);
        $response->assertJson(['data' => ['SaveAuthor' => true]]);
    }

    /**
     * @test
     */
    public function infiniteLoopDirectToMany(): void
    {
        $post = [
            'query' => 'mutation SaveAuthor($author: AuthorInput!) {
                SaveAuthor(author: $author)
            }',
            'variables' => [
                'author' => [
                    'name' => 'Some Author Name',
                    'books' => [
                        ['name' => 'Book Name'],
                    ],
                ],
            ],
            'operationName' => 'SaveAuthor',
        ];
        $response = $this->json('POST', '/graphql', $post);
        $response->assertJson(['data' => ['SaveAuthor' => true]]);
    }

    /**
     * @test
     */
    public function infiniteLoopIndirectToOne(): void
    {
        $post = [
            'query' => 'mutation SavePublisher($publisher: PublisherInput!) {
                SavePublisher(publisher: $publisher)
            }',
            'variables' => [
                'publisher' => [
                    'name' => 'Some Publisher Name',
                    'bestSellingAuthor' => [
                        'name' => 'Author Name',
                        'bestSellingBook' => [
                            'name' => 'Book Name',
                        ],
                    ],
                ],
            ],
            'operationName' => 'SavePublisher',
        ];
        $response = $this->json('POST', '/graphql', $post);
        $response->assertJson(['data' => ['SavePublisher' => true]]);
    }

    /**
     * @test
     */
    public function infiniteLoopIndirectToMany(): void
    {
        $post = [
            'query' => 'mutation SavePublisher($publisher: PublisherInput!) {
                SavePublisher(publisher: $publisher)
            }',
            'variables' => [
                'publisher' => [
                    'name' => 'Some Publisher Name',
                    'authors' => [
                        [
                            'name' => 'Author Name',
                            'books' => [
                                ['name' => 'Book Name'],<commit_msg>chore: remove attribute in favour of test name<commit_after><?php

declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\RecursionTest;

use Rebing\GraphQL\Tests\TestCase;
use Rebing\GraphQL\Tests\Unit\RecursionTest\Inputs\AuthorInput;
use Rebing\GraphQL\Tests\Unit\RecursionTest\Inputs\BookInput;
use Rebing\GraphQL\Tests\Unit\RecursionTest\Inputs\PublisherInput;
use Rebing\GraphQL\Tests\Unit\RecursionTest\Mutations\SaveAuthor;
use Rebing\GraphQL\Tests\Unit\RecursionTest\Mutations\SavePublisher;

class RecursionTest extends TestCase
{
    protected function getEnvironmentSetUp($app): void
    {
        parent::getEnvironmentSetUp($app);

        $app['config']->set('graphql.schemas.default', [
            'mutation' => [
                SaveAuthor::class,
                SavePublisher::class,
            ],
        ]);
        $app['config']->set('graphql.types', [
            AuthorInput::class,
            BookInput::class,
            PublisherInput::class,
        ]);
    }

    public function testInfiniteLoopDirectToOne(): void
    {
        $post = [
            'query' => 'mutation SaveAuthor($author: AuthorInput!) {
                SaveAuthor(author: $author)
            }',
            'variables' => [
                'author' => [
                    'name' => 'Some Author Name',
                    'bestSellingBook' => [
                        'name' => 'Book Name',
                    ],
                ],
            ],
            'operationName' => 'SaveAuthor',
        ];
        $response = $this->json('POST', '/graphql', $post);
        $response->assertJson(['data' => ['SaveAuthor' => true]]);
    }

    public function testInfiniteLoopDirectToMany(): void
    {
        $post = [
            'query' => 'mutation SaveAuthor($author: AuthorInput!) {
                SaveAuthor(author: $author)
            }',
            'variables' => [
                'author' => [
                    'name' => 'Some Author Name',
                    'books' => [
                        ['name' => 'Book Name'],
                    ],
                ],
            ],
            'operationName' => 'SaveAuthor',
        ];
        $response = $this->json('POST', '/graphql', $post);
        $response->assertJson(['data' => ['SaveAuthor' => true]]);
    }

    public function testInfiniteLoopIndirectToOne(): void
    {
        $post = [
            'query' => 'mutation SavePublisher($publisher: PublisherInput!) {
                SavePublisher(publisher: $publisher)
            }',
            'variables' => [
                'publisher' => [
                    'name' => 'Some Publisher Name',
                    'bestSellingAuthor' => [
                        'name' => 'Author Name',
                        'bestSellingBook' => [
                            'name' => 'Book Name',
                        ],
                    ],
                ],
            ],
            'operationName' => 'SavePublisher',
        ];
        $response = $this->json('POST', '/graphql', $post);
        $response->assertJson(['data' => ['SavePublisher' => true]]);
    }

    public function testInfiniteLoopIndirectToMany(): void
    {
        $post = [
            'query' => 'mutation SavePublisher($publisher: PublisherInput!) {
                SavePublisher(publisher: $publisher)
            }',
            'variables' => [
                'publisher' => [
                    'name' => 'Some Publisher Name',
                    'authors' => [
                        [
                            'name' => '<NAME>',
                            'books' => [
                                ['name' => 'Book Name'],
{'fraction_non_alphanumeric': 0.14387810140237325, 'fraction_numerical': 0.00026968716289104636, 'mean_word_length': 1.4390003288391977, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 96, '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': '1358054', 'n_tokens_mistral': 2025, 'n_tokens_neox': 1913, 'n_words': 315}