core /.dev/tests/Classes/Model/TmpVar.php

Language PHP Lines 110
MD5 Hash f6b162e79e3699b9780af9c2a6f950d6
Repository https://github.com/istran/core.git View Raw File
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
<?php
// vim: set ts=4 sw=4 sts=4 et:

/**
 * XLite\Model\Category class tests
 *
 * @category   LiteCommerce
 * @package    Tests
 * @subpackage Classes
 * @author     Creative Development LLC <info@cdev.ru>
 * @copyright  Copyright (c) 2010 Creative Development LLC <info@cdev.ru>. All rights reserved
 * @license    http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * @version    GIT: $Id: 2cbde48cd9c001b4697303ef7b175958a31229b7 $
 * @link       http://www.litecommerce.com/
 * @see        ____file_see____
 * @since      3.0.0
 */

class XLite_Tests_Model_TmpVar extends XLite_Tests_TestCase
{
    protected $entityData = array(
        'name'  => 'test',
        'value' => 'value',
    );

    /**
     * testCreate 
     * 
     * @return void
     * @access public
     * @see    ____func_see____
     * @since  3.0.0
     */
    public function testCreate()
    {
        $c = new \XLite\Model\TmpVar();

        $c->map($this->entityData);

        \XLite\Core\Database::getEM()->persist($c);
        \XLite\Core\Database::getEM()->flush();

        $this->assertTrue(0 < $c->getId(), 'check id');

        $id = $c->getId();

        \XLite\Core\Database::getEM()->clear();

        $c = \XLite\Core\Database::getRepo('XLite\Model\TmpVar')->find($id);

        $this->assertEquals($c->getName(), $this->entityData['name'], 'check name');
        $this->assertEquals($c->getValue(), $this->entityData['value'], 'check value');
    }

    public function testUpdate()
    {
        foreach (\XLite\Core\Database::getRepo('XLite\Model\TmpVar')->findAll() as $c) {
            \XLite\Core\Database::getEM()->remove($c);
        }
        \XLite\Core\Database::getEM()->flush();

        $c = new \XLite\Model\TmpVar();

        $c->map($this->entityData);

        \XLite\Core\Database::getEM()->persist($c);
        \XLite\Core\Database::getEM()->flush();

        $c->setName('zzz');

        $id = $c->getId();

        \XLite\Core\Database::getEM()->flush();

        \XLite\Core\Database::getEM()->clear();

        $c = \XLite\Core\Database::getRepo('XLite\Model\TmpVar')->find($id);

        $this->assertEquals('zzz', $c->getName(), 'check name');
    }

    public function testRemove()
    {
        foreach (\XLite\Core\Database::getRepo('XLite\Model\TmpVar')->findAll() as $c) {
            \XLite\Core\Database::getEM()->remove($c);
        }
        \XLite\Core\Database::getEM()->flush();

        $c = new \XLite\Model\TmpVar();
    
        $c->map($this->entityData);

        \XLite\Core\Database::getEM()->persist($c);
        \XLite\Core\Database::getEM()->flush();

        $id = $c->getId();

        \XLite\Core\Database::getEM()->remove($c);

        \XLite\Core\Database::getEM()->flush();

        \XLite\Core\Database::getEM()->clear();

        $c = \XLite\Core\Database::getRepo('XLite\Model\TmpVar')->find($id);

        $this->assertTrue(is_null($c), 'check entity');
    }

}
Back to Top