<commit_before><?php
/**
 * This file is part of Railt package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
declare(strict_types=1);

namespace Railt\Tests\Compiler;

use Railt\Compiler\Reflection\Builder\DocumentBuilder;
use Railt\Reflection\Contracts\Definitions\ObjectDefinition;
use Railt\Reflection\Contracts\Document;

/**
 * Class ExtendTestCase
 */
class ExtendTestCase extends AbstractCompilerTestCase
{
    /**
     * @return array
     * @throws \League\Flysystem\FileNotFoundException
     * @throws \LogicException
     */
    public function provider(): array
    {
        $schema = <<<'GraphQL'
type Test {
    id: String
    createdAt: DateTime!
}

extend type Test @deprecated(reason: "Test") {
    id(arg: String): ID
    updatedAt: DateTime
}
GraphQL;

        return $this->dataProviderDocuments($schema);
    }

    /**
     * @dataProvider provider
     *
     * @param Document|DocumentBuilder $document
     * @return void
     * @throws \PHPUnit\Framework\Exception
     */
    public function testType(Document $document): void
    {
        /** @var ObjectDefinition $type */
        $type = $document->getTypeDefinition('Test');

        static::assertNotNull($type);
        static::assertNotNull($type->getField('id'));

        static::assertEquals(3, $type->getNumberOfFields());
        static::assertCount(3, $type->getFields());
    }

    /**
     * @dataProvider provider
     *
     * @param Document|DocumentBuilder $document
     * @return void
     * @throws \PHPUnit\Framework\Exception
     */
    public function testTypeFields(Document $document): void
    {
        /** @var ObjectDefinition $type */
        $type = $document->getTypeDefinition('Test');

        static::assertNotNull($type);

        static::assertTrue($type->hasField('id'));
        static::assertTrue($type->hasField('createdAt'));
        static::assertTrue($type->hasField('updatedAt'));
        static::assertFalse($type->hasField('deprecated'));
    }

    /**
     * @dataProvider provider
     *
     * @param Document|DocumentBuilder $document
     * @return void
     * @throws \PHPUnit\Framework\Exception
     */
    public function testTypeArguments(Document $document): void
    {
        /** @var ObjectDefinition $type */
        $type = $document->getTypeDefinition('Test');
        static::assertNotNull($type);

        $field = $type->getField('id');
        static::assertNotNull($field);

        static::assertTrue($field->hasArgument('arg'));
        static::assertNotNull($field->getArgument('arg'));
        static::assertCount(1, $field->getArguments());
    }
}<commit_msg>Add extend Nullable overriden by NonNull tests<commit_after><?php
/**
 * This file is part of Railt package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
declare(strict_types=1);

namespace Railt\Tests\Compiler;

use Railt\Compiler\Reflection\Builder\DocumentBuilder;
use Railt\Reflection\Contracts\Definitions\ObjectDefinition;
use Railt\Reflection\Contracts\Document;

/**
 * Class ExtendTestCase
 */
class ExtendTestCase extends AbstractCompilerTestCase
{
    /**
     * @return array
     * @throws \League\Flysystem\FileNotFoundException
     * @throws \LogicException
     */
    public function provider(): array
    {
        $schema = <<<'GraphQL'
type Test {
    id: String
    createdAt: DateTime!
}

extend type Test @deprecated(reason: "Test") {
    id(arg: String): ID!
    updatedAt: DateTime
}
GraphQL;

        return $this->dataProviderDocuments($schema);
    }

    /**
     * @dataProvider provider
     *
     * @param Document|DocumentBuilder $document
     * @return void
     * @throws \PHPUnit\Framework\Exception
     */
    public function testType(Document $document): void
    {
        /** @var ObjectDefinition $type */
        $type = $document->getTypeDefinition('Test');

        static::assertNotNull($type);
        static::assertNotNull($type->getField('id'));

        static::assertEquals(3, $type->getNumberOfFields());
        static::assertCount(3, $type->getFields());
    }

    /**
     * @dataProvider provider
     *
     * @param Document|DocumentBuilder $document
     * @return void
     * @throws \PHPUnit\Framework\Exception
     */
    public function testTypeFields(Document $document): void
    {
        /** @var ObjectDefinition $type */
        $type = $document->getTypeDefinition('Test');

        static::assertNotNull($type);

        static::assertTrue($type->hasField('id'));
        static::assertTrue($type->hasField('createdAt'));
        static::assertTrue($type->hasField('updatedAt'));
        static::assertFalse($type->hasField('deprecated'));
    }

    /**
     * @dataProvider provider
     *
     * @param Document|DocumentBuilder $document
     * @return void
     * @throws \PHPUnit\Framework\Exception
     */
    public function testTypeArguments(Document $document): void
    {
        /** @var ObjectDefinition $type */
        $type = $document->getTypeDefinition('Test');
        static::assertNotNull($type);

        $field = $type->getField('id');
        static::assertNotNull($field);
        static::assertTrue($field->isNonNull());

        static::assertTrue($field->hasArgument('arg'));
        static::assertNotNull($field->getArgument('arg'));
        static::assertCount(1, $field->getArguments());
    }
}
{'fraction_non_alphanumeric': 0.1387525004546281, 'fraction_numerical': 0.0014548099654482633, 'mean_word_length': 3.0892193308550184, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 34, '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': '5429864', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1465, 'n_words': 305}