<commit_before><?php
/**
 *
 */

namespace Mvc5\Test\Plugin;

use Mvc5\App;
use Mvc5\Config;
use Mvc5\Log\ErrorLog;
use Mvc5\Plugin\Plugin;
use Mvc5\Test\Test\TestCase;

class PluginTest
    extends TestCase
{
    /**
     *
     */
    function test_defaults()
    {
        $plugin = new Plugin('foo');

        $this->assertEquals('foo', $plugin->name());
        $this->assertEquals([], $plugin->args());
        $this->assertEquals([], $plugin->calls());
        $this->assertEquals('item', $plugin->param());
        $this->assertFalse($plugin->merge());
    }

    /**
     *
     */
    function test_not_parent_type_plugin()
    {
        $plugin = new Plugin(Config::class, ['config' => ['foo' => 'bar']]);

        $app = new App([
            'services' => [
                Config::class => Config::class
            ]<commit_msg>array_merge required for plugin calls<commit_after><?php
/**
 *
 */

namespace Mvc5\Test\Plugin;

use Mvc5\App;
use Mvc5\Config;
use Mvc5\Log\ErrorLog;
use Mvc5\Plugin\Plugin;
use Mvc5\Test\Test\TestCase;

class PluginTest
    extends TestCase
{
    /**
     *
     */
    function test_defaults()
    {
        $plugin = new Plugin('foo');

        $this->assertEquals('foo', $plugin->name());
        $this->assertEquals([], $plugin->args());
        $this->assertEquals([], $plugin->calls());
        $this->assertEquals('item', $plugin->param());
        $this->assertFalse($plugin->merge());
    }

    /**
     * @throws \Throwable
     */
    function test_merge_calls_override_parent_method()
    {
        $app = new App([
            'services' => [
                'parent' => new Plugin(Config::class, [['a' => '1']], ['set' => ['b' => '2']]),
                'child' => new Plugin('parent', [], ['set' => ['c' => '3']], null, true)
            ]
        ]);

        $this->assertEquals(
            new Config(['a' => '1', 'c' => '3']), $app->plugin('child')
        );
    }

    /**
     * @throws \Throwable
     */
    function test_merge_calls_repeat_method()
    {
        $app = new App([
            'services' => [
                'parent' => new Plugin(Config::class, [['a' => '1']], [['set', 'b', '2']]),
                'child' => new Plugin('parent', [], [['set', 'c', '3']], null, true)
            ]
        ]);

        $this->assertEquals(
            new Config(['a' => '1', 'b' => '2', 'c' => '3']), $app->plugin('child')
        );
    }

    /**
     *
     */
    function test_not_parent_type_plugin()
    {
        $plugin = new Plugin(Config::class, ['config' => ['foo' => 'bar']]);

        $app = new App([
            'services' => [
                Config::class => Config::class
            ]
{'fraction_non_alphanumeric': 0.20940649496080627, 'fraction_numerical': 0.008585293019783502, 'mean_word_length': 2.018018018018018, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 52, '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': '3594568', 'n_tokens_mistral': 868, 'n_tokens_neox': 852, 'n_words': 158}