| 1 | <?php␊ |
| 2 | /* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */␊ |
| 3 | /*␊ |
| 4 | # ***** BEGIN LICENSE BLOCK *****␊ |
| 5 | # This file is part of Plume Framework, a simple PHP Application Framework.␊ |
| 6 | # Copyright (C) 2001-2007 Loic d'Anterroches and contributors.␊ |
| 7 | #␊ |
| 8 | # Plume Framework is free software; you can redistribute it and/or modify␊ |
| 9 | # it under the terms of the GNU Lesser General Public License as published by␊ |
| 10 | # the Free Software Foundation; either version 2.1 of the License, or␊ |
| 11 | # (at your option) any later version.␊ |
| 12 | #␊ |
| 13 | # Plume Framework is distributed in the hope that it will be useful,␊ |
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of␊ |
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the␊ |
| 16 | # GNU Lesser General Public License for more details.␊ |
| 17 | #␊ |
| 18 | # You should have received a copy of the GNU Lesser General Public License␊ |
| 19 | # along with this program; if not, write to the Free Software␊ |
| 20 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA␊ |
| 21 | #␊ |
| 22 | # ***** END LICENSE BLOCK ***** */␊ |
| 23 | ␊ |
| 24 | class Pluf_Tests_Model_CompressedField_Model extends Pluf_Model␊ |
| 25 | {␊ |
| 26 | public $_model = __CLASS__; ␊ |
| 27 | ␊ |
| 28 | function init()␊ |
| 29 | {␊ |
| 30 | $this->_a['verbose'] = 'compressed';␊ |
| 31 | $this->_a['table'] = 'compressed';␊ |
| 32 | $this->_a['model'] = __CLASS__;␊ |
| 33 | $this->_a['cols'] = array(␊ |
| 34 | // It is mandatory to have an "id" column.␊ |
| 35 | 'id' =>␊ |
| 36 | array(␊ |
| 37 | 'type' => 'Pluf_DB_Field_Sequence',␊ |
| 38 | //It is automatically added.␊ |
| 39 | 'blank' => true, ␊ |
| 40 | ),␊ |
| 41 | 'compressed' =>␊ |
| 42 | array(␊ |
| 43 | 'type' => 'Pluf_DB_Field_Compressed',␊ |
| 44 | ),␊ |
| 45 | );␊ |
| 46 | }␊ |
| 47 | }␊ |
| 48 | ␊ |
| 49 | ␊ |
| 50 | class Pluf_Tests_Model_CompressedField extends UnitTestCase {␊ |
| 51 | ␊ |
| 52 | function __construct() ␊ |
| 53 | {␊ |
| 54 | parent::__construct('Test the compressed field.');␊ |
| 55 | }␊ |
| 56 | ␊ |
| 57 | function testCreate()␊ |
| 58 | {␊ |
| 59 | $db = Pluf::db();␊ |
| 60 | $schema = new Pluf_DB_Schema($db);␊ |
| 61 | $m = new Pluf_Tests_Model_CompressedField_Model();␊ |
| 62 | $schema->model = $m;␊ |
| 63 | $schema->createTables();␊ |
| 64 | $m->compressed = 'Youplaboum';␊ |
| 65 | $m->create();␊ |
| 66 | $this->assertEqual(1, $m->id);␊ |
| 67 | $m = new Pluf_Tests_Model_CompressedField_Model(1);␊ |
| 68 | $this->assertEqual('Youplaboum', $m->compressed);␊ |
| 69 | $schema->dropTables();␊ |
| 70 | }␊ |
| 71 | } |