<commit_before><?php
/**
 * @group Model
 * @group Model_Mail
 * @group Mail
 */
class Vps_Model_Mail_ModelTest extends PHPUnit_Framework_TestCase
{
    private $_fnf;

    public function setUp()
    {
        $this->_fnf = new Vps_Model_FnF(array(
            'data' => array(
                array('id' => 4, 'save_date' => '2008-10-29 08:15:00', 'is_spam' => 0, serialize(array()), serialize(array()))
            ),
            'columns' => array('id', 'save_date', 'is_spam', 'mail_sent', 'serialized_mail_vars', 'serialized_mail_essentials'),
            'primaryKey' => 'id'
        ));
    }

    public function testRow()
    {
        $model = new Vps_Model_Mail(array(
            'proxyModel' => $this->_fnf,
            'tpl' => 'UserActivation',
        ));

        // normal
        $row = $model->getRow(4);
        $row->save_date = 'test';
        $this->assertEquals('test', $row->save_date);

        // im mail-vars sibling
        $row->blubb = 'bla';
        $this->assertEquals('bla', $row->blubb);
    }

    public function testAdditionalStore()
    {
        $addStore = new Vps_Model_FnF();

        // händisches MockMail weil nur der class-name übergeben werden darf, kein objekt
        Vps_Model_Mail_MockMail::resetCalls();

        $model = new Vps_Model_Mail(array(
            'proxyModel' => $this->_fnf,
            'tpl' => 'UserActivation',
            'mailerClass' => 'Vps_Model_Mail_MockMail',
            'spamFields' => array(),
            'additionalStore' => $addStore
        ));
        $row = $model->createRow();
        $row->addTo('<EMAIL>');
        $row->setFrom('<EMAIL>', 'Vps');
        $row->subject = 'foo sub';
        $row->foo = 'bar';
        $row->foo2 = 'bar2';
        $row->save();

        $addRow = $addStore->getRows()->current();
        $this->assertEquals('bar', $addRow->foo);
        $this->assertEquals('bar2', $addRow->foo2);
        $this->assertEquals('foo sub', $addRow->subject);
    }

    public function testMail()
    {
        // händisches MockMail weil nur der class-name übergeben werden darf, kein objekt
        Vps_Model_Mail_MockMail::resetCalls();

        $model = new Vps_Model_Mail(array(
            'proxyModel' => $this->_fnf,
            'tpl' => 'UserActivation',
            'mailerClass' => 'Vps_Model_Mail_MockMail',
            'spamFields' => array()
        ));
        $row = $model->createRow();
        $row->addTo('<EMAIL>');
        $row->addTo('<EMAIL>', 'm2');
        $row->setFrom('<EMAIL>', 'Vps');
        $row->addCc('<EMAIL>', 'cc');
        $row->addBcc('<EMAIL>', 'bcc');
        $row->addHeader('X-MyHeader', '321');
        $row->subject = 'Test subject';
        $row->foo = 'bar';
        $row->save();

        $this->assertEquals('bar', $row->foo);
        $this->assertEquals('Test subject', $row->subject);
        $this->assertEquals(array(
            'subject' => 'Test subject',
            'foo' => 'bar'
        ), Vps_Model_Mail_MockMail::$data);

        $this->assertEquals(2, count(Vps_Model_Mail_MockMail::$addToCalled));
        $this->assertEquals(array(
            array('<EMAIL>', ''),
            array('<EMAIL>', 'm2')
        ), Vps_Model_Mail_MockMail::$addToCalled);

        $this->assertEquals(
            array('<EMAIL>', 'Vps'),
            Vps_Model_Mail_MockMail::$setFromCalled
        );

        $this->assertEquals(array(
                array('<EMAIL>', 'cc')
            ), Vps_Model_Mail_MockMail::$addCcCalled
        );

        $this->assertEquals(
            array('<EMAIL>'),
            Vps_Model_Mail_MockMail::$addBccCalled
        );

        $this->assertContains(
            array('X-MyHeader', '321', false),
            Vps_Model_Mail_MockMail::$addHeaderCalled<commit_msg>Test angepasst: im MockMail waren mehr Daten drinnen, jetzt wird es anders geprueft<commit_after><?php
/**
 * @group Model
 * @group Model_Mail
 * @group Mail
 */
class Vps_Model_Mail_ModelTest extends PHPUnit_Framework_TestCase
{
    private $_fnf;

    public function setUp()
    {
        $this->_fnf = new Vps_Model_FnF(array(
            'data' => array(
                array('id' => 4, 'save_date' => '2008-10-29 08:15:00', 'is_spam' => 0, serialize(array()), serialize(array()))
            ),
            'columns' => array('id', 'save_date', 'is_spam', 'mail_sent', 'serialized_mail_vars', 'serialized_mail_essentials'),
            'primaryKey' => 'id'
        ));
    }

    public function testRow()
    {
        $model = new Vps_Model_Mail(array(
            'proxyModel' => $this->_fnf,
            'tpl' => 'UserActivation',
        ));

        // normal
        $row = $model->getRow(4);
        $row->save_date = 'test';
        $this->assertEquals('test', $row->save_date);

        // im mail-vars sibling
        $row->blubb = 'bla';
        $this->assertEquals('bla', $row->blubb);
    }

    public function testAdditionalStore()
    {
        $addStore = new Vps_Model_FnF();

        // händisches MockMail weil nur der class-name übergeben werden darf, kein objekt
        Vps_Model_Mail_MockMail::resetCalls();

        $model = new Vps_Model_Mail(array(
            'proxyModel' => $this->_fnf,
            'tpl' => 'UserActivation',
            'mailerClass' => 'Vps_Model_Mail_MockMail',
            'spamFields' => array(),
            'additionalStore' => $addStore
        ));
        $row = $model->createRow();
        $row->addTo('<EMAIL>');
        $row->setFrom('<EMAIL>', 'Vps');
        $row->subject = 'foo sub';
        $row->foo = 'bar';
        $row->foo2 = 'bar2';
        $row->save();

        $addRow = $addStore->getRows()->current();
        $this->assertEquals('bar', $addRow->foo);
        $this->assertEquals('bar2', $addRow->foo2);
        $this->assertEquals('foo sub', $addRow->subject);
    }

    public function testMail()
    {
        // händisches MockMail weil nur der class-name übergeben werden darf, kein objekt
        Vps_Model_Mail_MockMail::resetCalls();

        $model = new Vps_Model_Mail(array(
            'proxyModel' => $this->_fnf,
            'tpl' => 'UserActivation',
            'mailerClass' => 'Vps_Model_Mail_MockMail',
            'spamFields' => array()
        ));
        $row = $model->createRow();
        $row->addTo('<EMAIL>');
        $row->addTo('<EMAIL>', 'm2');
        $row->setFrom('<EMAIL>', 'Vps');
        $row->addCc('<EMAIL>', 'cc');
        $row->addBcc('<EMAIL>', 'bcc');
        $row->addHeader('X-MyHeader', '321');
        $row->subject = 'Test subject';
        $row->foo = 'bar';
        $row->save();

        $this->assertEquals('bar', $row->foo);
        $this->assertEquals('Test subject', $row->subject);
        $this->assertEquals('Test subject', Vps_Model_Mail_MockMail::$data['subject']);

        $this->assertEquals(2, count(Vps_Model_Mail_MockMail::$addToCalled));
        $this->assertEquals(array(
            array('<EMAIL>', ''),
            array('<EMAIL>', 'm2')
        ), Vps_Model_Mail_MockMail::$addToCalled);

        $this->assertEquals(
            array('<EMAIL>', 'Vps'),
            Vps_Model_Mail_MockMail::$setFromCalled
        );

        $this->assertEquals(array(
                array('<EMAIL>', 'cc')
            ), Vps_Model_Mail_MockMail::$addCcCalled
        );

        $this->assertEquals(
            array('<EMAIL>'),
            Vps_Model_Mail_MockMail::$addBccCalled
        );

        $this->assertContains(
            array('X-MyHeader', '321', false),
            Vps_Model_Mail_MockMail::$addHeaderCalled
{'fraction_non_alphanumeric': 0.17364155706124618, 'fraction_numerical': 0.007971303308090873, 'mean_word_length': 2.2392426850258174, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 157, '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': '2472713', 'n_tokens_mistral': 2420, 'n_tokens_neox': 2404, 'n_words': 399}