<commit_before><?php
namespace Amiss\Test\Acceptance\Manager;

use Amiss\Sql\Manager;

class EventTest extends \CustomMapperTestCase
{
    private $callback;

    function doEvent(...$args)
    {
        $cb = $this->callback;
        $cb(...$args);
    }

    function testBeforeInsert()
    {
        list ($nm, $ns) = $this->createDefaultNoteManager('
            /**
             * :amiss = {"on": {"beforeInsert": ["a", "b"]}};
             */
            class Pants {
                /** :amiss = {"field": true}; */
                public $foo;

                function a() { $this->foo = $this->foo * 2; }
                function b() { $this->foo = $this->foo + 3; }
            }
        ');
        $nm->on['beforeInsert'][] = function($object) {
            $object->foo -= 5;
        };
        $result = ((123 * 2) + 3) - 5; // 244
        $cls = "$ns\\Pants";
        $o = new $cls;
        $o->foo = 123;
        $nm->insert($o, $nm->getMeta('Pants'));
        $o = $nm->getList('Pants');
        $this->assertEquals($result, $o[0]->foo);
    }

    function testMetaAfterInsert()
    {<commit_msg>removed crap<commit_after><?php
namespace Amiss\Test\Acceptance\Manager;

use Amiss\Sql\Manager;

class EventTest extends \CustomMapperTestCase
{
    function testBeforeInsert()
    {
        list ($nm, $ns) = $this->createDefaultNoteManager('
            /**
             * :amiss = {"on": {"beforeInsert": ["a", "b"]}};
             */
            class Pants {
                /** :amiss = {"field": true}; */
                public $foo;

                function a() { $this->foo = $this->foo * 2; }
                function b() { $this->foo = $this->foo + 3; }
            }
        ');
        $nm->on['beforeInsert'][] = function($object) {
            $object->foo -= 5;
        };
        $result = ((123 * 2) + 3) - 5; // 244
        $cls = "$ns\\Pants";
        $o = new $cls;
        $o->foo = 123;
        $nm->insert($o, $nm->getMeta('Pants'));
        $o = $nm->getList('Pants');
        $this->assertEquals($result, $o[0]->foo);
    }

    function testMetaAfterInsert()
    {
{'fraction_non_alphanumeric': 0.1944049312470365, 'fraction_numerical': 0.015173067804646752, 'mean_word_length': 1.6211180124223603, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 30, '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': '4723866', 'n_tokens_mistral': 699, 'n_tokens_neox': 657, 'n_words': 132}