<commit_before><?php
namespace Phwoolcon\Tests;

use Phalcon\Db\Column;
use Phalcon\Validation;
use Phalcon\Validation\Validator\StringLength;
use Phwoolcon\Db;
use Phwoolcon\Model;

/**
 * Class TestModel
 * @package Phwoolcon\Tests
 *
 * @method string getKey()
 * @method mixed getValue()
 * @method $this setValue(mixed $value)
 */
class TestModel extends Model
{
    protected $_table = 'test_model';
    protected $_pk = 'key';
    protected $_jsonFields = ['value'];

    protected function createTable()
    {
        $db = Db::connection();
        $db->createTable($this->_table, null, [
            'columns' => [
                new Column('key', [
                    'type' => Column::TYPE_VARCHAR,
                    'size' => 32,
                    'notNull' => true,
                    'primary' => true,
                ]),
                new Column('value', [
                    'type' => Column::TYPE_TEXT,
                ]),
                new Column('created_at', [
                    'type' => Column::TYPE_BIGINTEGER,
                    'size' => 20,
                    'unsigned' => true,
                    'notNull' => false,
                ]),
                new Column('updated_at', [
                    'type' => Column::TYPE_BIGINTEGER,
                    'size' => 20,
                    'unsigned' => true,
                    'notNull' => false,
                ]),
            ],
        ]);
    }

    public function initialize()
    {
        parent::initialize();
        $db = Db::connection();
        $db->tableExists($this->_table) or $this->createTable();
        $db->delete($this->_table);
    }

    public function validation()
    {
        $validator = new Validation();
        $validator->add('key', new StringLength([
            'min' => 3,
            'max' => 32,
        ]));
        $this->validate($validator);
        return parent::validation();
    }<commit_msg>test: phalcon 2.1.x and 2.0.x compatibility<commit_after><?php
namespace Phwoolcon\Tests;

use Phalcon\Db\Column;
use Phalcon\Validation;
use Phalcon\Validation\Validator\StringLength;
use Phalcon\Version;
use Phwoolcon\Db;
use Phwoolcon\Model;

/**
 * Class TestModel
 * @package Phwoolcon\Tests
 *
 * @method string getKey()
 * @method mixed getValue()
 * @method $this setValue(mixed $value)
 */
class TestModel extends Model
{
    protected $_table = 'test_model';
    protected $_pk = 'key';
    protected $_jsonFields = ['value'];

    protected function createTable()
    {
        $db = Db::connection();
        $db->createTable($this->_table, null, [
            'columns' => [
                new Column('key', [
                    'type' => Column::TYPE_VARCHAR,
                    'size' => 32,
                    'notNull' => true,
                    'primary' => true,
                ]),
                new Column('value', [
                    'type' => Column::TYPE_TEXT,
                ]),
                new Column('created_at', [
                    'type' => Column::TYPE_BIGINTEGER,
                    'size' => 20,
                    'unsigned' => true,
                    'notNull' => false,
                ]),
                new Column('updated_at', [
                    'type' => Column::TYPE_BIGINTEGER,
                    'size' => 20,
                    'unsigned' => true,
                    'notNull' => false,
                ]),
            ],
        ]);
    }

    public function initialize()
    {
        parent::initialize();
        $db = Db::connection();
        $db->tableExists($this->_table) or $this->createTable();
        $db->delete($this->_table);
    }

    public function validation()
    {
        if (Version::getId() > '2010000') {
            $validator = new Validation();
            $validator->add('key', new StringLength([
                'min' => 3,
                'max' => 32,
            ]));
        } else {
            $validator = new \Phalcon\Mvc\Model\Validator\StringLength([
                'min' => 3,
                'max' => 32,
            ]);
        }
        $this->validate($validator);
        return parent::validation();
    }
{'fraction_non_alphanumeric': 0.14491362763915547, 'fraction_numerical': 0.007677543186180422, 'mean_word_length': 1.4845053635280094, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 56, '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': '4969243', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1115, 'n_words': 234}