<commit_before><?php

declare(strict_types=1);

namespace BEAR\Package;

use BEAR\Resource\RenderInterface;
use BEAR\Sunday\Extension\Application\AppInterface;
use FakeVendor\HelloWorld\Module\App;
use FakeVendor\HelloWorld\Resource\Page\Index;
use PHPUnit\Framework\TestCase;
use Ray\Di\AbstractModule;

class AppInjectorTest extends TestCase
{
    public function testGetInstance()
    {
        $app = (new AppInjector('FakeVendor\HelloWorld', 'prod-cli-app'))->getInstance(AppInterface::class);
        $this->assertInstanceOf(App::class, $app);
    }

    public function testInvalidContext()
    {
        $this->expectException(\BEAR\Package\Exception\InvalidContextException::class);

        (new AppInjector('FakeVendor\HelloWorld', '__invalid__'))->getInstance(AppInterface::class);
    }

    public function testInvalidInterface()
    {
        $this->expectException(\Ray\Compiler\Exception\NotCompiled::class);

        (new AppInjector('FakeVendor\HelloWorld', 'prod-cli-app'))->getInstance('__Invalid__');
    }

    public function testGetOverrideInstance()
    {
        /** @var RenderInterface $mock */
        $mock = $this->createMock(RenderInterface::class);
        $module = new class($mock) extends AbstractModule {
            private $mock;

            public function __construct(RenderInterface $mock)
            {
                $this->mock = $mock;
                parent::__construct();
            }

            protected function configure()
            {
                $this->bind(RenderInterface::class)->toInstance($this->mock);
            }
        };
        $appInjector = (new AppInjector('FakeVendor\HelloWorld', 'hal-app'));
        $renderer = $appInjector->getOverrideInstance($module, RenderInterface::class);<commit_msg>add phpdoc<commit_after><?php

declare(strict_types=1);

namespace BEAR\Package;

use BEAR\Resource\RenderInterface;
use BEAR\Sunday\Extension\Application\AppInterface;
use FakeVendor\HelloWorld\Module\App;
use FakeVendor\HelloWorld\Resource\Page\Index;
use PHPUnit\Framework\TestCase;
use Ray\Di\AbstractModule;

class AppInjectorTest extends TestCase
{
    public function testGetInstance()
    {
        $app = (new AppInjector('FakeVendor\HelloWorld', 'prod-cli-app'))->getInstance(AppInterface::class);
        $this->assertInstanceOf(App::class, $app);
    }

    public function testInvalidContext()
    {
        $this->expectException(\BEAR\Package\Exception\InvalidContextException::class);

        (new AppInjector('FakeVendor\HelloWorld', '__invalid__'))->getInstance(AppInterface::class);
    }

    public function testInvalidInterface()
    {
        $this->expectException(\Ray\Compiler\Exception\NotCompiled::class);

        (new AppInjector('FakeVendor\HelloWorld', 'prod-cli-app'))->getInstance('__Invalid__');
    }

    public function testGetOverrideInstance()
    {
        /** @var RenderInterface $mock */
        $mock = $this->createMock(RenderInterface::class);
        $module = new class($mock) extends AbstractModule {
            /**
             * @var RenderInterface
             */
            private $mock;

            public function __construct(RenderInterface $mock)
            {
                $this->mock = $mock;
                parent::__construct();
            }

            protected function configure()
            {
                $this->bind(RenderInterface::class)->toInstance($this->mock);
            }
        };
        $appInjector = (new AppInjector('FakeVendor\HelloWorld', 'hal-app'));
        $renderer = $appInjector->getOverrideInstance($module, RenderInterface::class);
{'fraction_non_alphanumeric': 0.1285595797622339, 'fraction_numerical': 0.000552944429084877, 'mean_word_length': 2.9977900552486187, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '1043607', 'n_tokens_mistral': 991, 'n_tokens_neox': 986, 'n_words': 154}