public function testIssetWithProxySiblings() { $fnf = new Kwf_Model_FnF(array('columns' => array('id', 'name', 'data'), 'data' => array(array('id' => 4, 'name' => 'foo', 'data' => json_encode(array('name1' => 'foo1')))))); $model = new Kwf_Model_Proxy(array('proxyModel' => $fnf, 'siblingModels' => array(new Kwf_Model_Field(array('fieldName' => 'data', 'columns' => array('name1')))))); $this->assertEquals(array('id', 'name', 'data'), $fnf->getColumns()); $this->assertTrue($fnf->hasColumn('id')); $this->assertTrue($fnf->hasColumn('name')); $this->assertFalse($fnf->hasColumn('name1')); $this->assertEquals(array('id', 'name', 'data', 'name1'), $model->getColumns()); $this->assertTrue($model->hasColumn('id')); $this->assertTrue($model->hasColumn('name')); $this->assertTrue($model->hasColumn('name1')); $row = $model->getRow(4); // isset $this->assertTrue(isset($row->name)); $this->assertFalse(isset($row->bar)); $this->assertTrue(isset($row->name1)); // get $this->assertEquals(4, $row->id); $this->assertEquals('foo', $row->name); $this->assertEquals('foo1', $row->name1); // set $row->name = 'bar'; $this->assertEquals('bar', $row->name); }
public function testDefaultValues() { $model = new Kwf_Model_FnF(array('columns' => array('id', 'foo', 'data'), 'data' => array(array('id' => 1, 'foo' => 'bar', 'data' => '')), 'dependentModels' => array('Child' => new Kwf_Model_FieldRows(array('fieldName' => 'data', 'default' => array('foo' => 'defaultFoo')))))); $row = $model->getRow(1); $cRow = $row->createChildRow('Child'); $this->assertEquals('defaultFoo', $cRow->foo); }
public function testAutoFillId() { $model = new Kwf_Model_FnF(array('data' => array(), 'filters' => array('test' => new Kwf_Filter_Row_AutoFill('x{id}')))); $row = $model->createRow(); $row->foo = 'foo4'; $row->save(); $this->assertEquals('x1', $model->getRow(1)->test); }
public function testValidate() { $model = new Kwf_Model_FnF(); $row = $model->createRow(); $this->assertEquals(array(), $this->_textField->validate($row, array('test12' => 'foobar'))); // eigenes feld weil beim vorigen _addValidators schon augerufen wurde $newTextField = new Kwf_Form_Field_TextField('test123'); $newTextField->setVtype('email'); $this->assertEquals(1, count($newTextField->validate($row, array('test123' => 'foobar')))); $this->assertEquals(0, count($newTextField->validate($row, array('test123' => '*****@*****.**')))); }
protected function _initFields() { $m = new Kwf_Model_FnF(); $row = $m->createRow(); $row->id = 1; $row->fs = 1; $row->asdf = 'Test'; $row->save(); $this->_form->setModel($m); $fs = $this->_form->add(new Kwf_Form_Container_FieldSet('Foobar'))->setCheckboxToggle(true)->setCheckboxName('fs'); $fs->add(new Kwf_Form_Field_TextField('asdf', 'Asdf')); }
public function testWhereNotEquals() { $model = new Kwf_Model_FnF(); $model->setData(array(array('id' => 1, 'value' => 'foo'), array('id' => 2, 'value' => 'bar'), array('id' => 3, 'value' => 'baz'), array('id' => 4, 'value' => 'buz'))); /* $select = $model->select(); $select->whereNotEquals('value', 'foo'); $this->_assertIds($model, $select, array(2, 3, 4)); */ $select = $model->select(); $select->whereNotEquals('value', array('foo', 'baz')); $this->_assertIds($model, $select, array(2, 4)); // $this->assertEquals($model->countRows($select), 2); }
public function testSkipFilter() { $model = new Kwf_Model_FnF(array('data' => array(), 'filters' => array('test' => new Kwf_Filter_Row_AutoFill('abc')))); $row = $model->createRow(); $row->foo = 'foo4'; $row->skip = 0; $row->test = 'bam'; $row->save(); $this->assertEquals('abc', $model->getRow(1)->test); $row->skip = 1; $row->save(); $row->test = 'bam'; $this->assertEquals('bam', $model->getRow(1)->test); }
public function testIt() { $model = new Kwf_Model_FnF(array('columns' => array(), 'data' => array(array('id' => 1, 'foo' => 'bar', 'data' => serialize(array('autoId' => 2, 'data' => array(array('id' => 1, 'blub' => 'blub1', 'foo' => 'foo'), array('id' => 2, 'blub' => 'blub2')))))), 'dependentModels' => array('Child' => new Kwf_Model_RowsSubModel_Proxy(array('proxyModel' => new Kwf_Model_FieldRows(array('fieldName' => 'data'))))))); $row = $model->getRow(1); $this->assertEquals($row->foo, 'bar'); $rows = $row->getChildRows('Child'); $this->assertEquals(count($rows), 2); $this->assertEquals($rows->current()->blub, 'blub1'); $this->assertEquals($rows->current()->id, 1); $rows->current()->foo = 'foo'; $rows->current()->save(); $row->blub1 = 'blub1'; $row->save(); $this->assertEquals($model->getData(), array(array('id' => 1, 'foo' => 'bar', 'data' => serialize(array('autoId' => 2, 'data' => array(array('id' => 1, 'blub' => 'blub1', 'foo' => 'foo'), array('id' => 2, 'blub' => 'blub2')))), 'blub1' => 'blub1'))); }
public function testExpr() { $model = new Kwf_Model_FnF(array('columns' => array('id', 'date'), 'data' => array(array('id' => 1, 'date' => '2013-12-04'), array('id' => 2, 'date' => '2003-12-05')), 'exprs' => array('year1' => new Kwf_Model_Select_Expr_Date_Year('date'), 'year2' => new Kwf_Model_Select_Expr_Date_Year('date', Kwf_Model_Select_Expr_Date_Year::FORMAT_DIGITS_TWO), 'format1' => new Kwf_Model_Select_Expr_Date_Format('date'), 'format2' => new Kwf_Model_Select_Expr_Date_Format('date', 'd.m.Y')))); $this->assertEquals($model->getRow(1)->year1, 2013); $this->assertEquals($model->getRow(2)->year1, 2003); $this->assertEquals($model->getRow(1)->year2, 13); $this->assertEquals($model->getRow(2)->year2, 03); $this->assertEquals($model->getRow(1)->format1, '2013-12-04'); $this->assertEquals($model->getRow(2)->format1, '2003-12-05'); $this->assertEquals($model->getRow(1)->format2, '04.12.2013'); $this->assertEquals($model->getRow(2)->format2, '05.12.2003'); }
public function __construct($config = array()) { $config['columns'] = array(); $config['primaryKey'] = 'component_id'; $config['data'] = array(array('component_id' => 'root-master_table', 'table_style' => 'standard')); parent::__construct($config); }
public function __construct($config = array()) { $config['columns'] = array(); $config['primaryKey'] = 'id'; $config['data'] = array(array('id' => 2, 'visible' => 1, 'component_id' => 'root-en_table', 'master_id' => 1, 'data' => '[]'), array('id' => 1, 'visible' => 1, 'component_id' => 'root-en_table', 'column1' => 'Abc', 'column3' => '234', 'master_id' => 2)); parent::__construct($config); }
public function __construct() { $config['columns'] = array(); $config['primaryKey'] = 'component_id'; $config['data'] = array(array('component_id' => 'root-en-cat1_1', 'visible' => true, 'name' => 'Foo1en', 'filename' => 'foo1en'), array('component_id' => 'root-en-cat1_2', 'visible' => true, 'name' => 'Foo2en', 'filename' => 'foo2en'), array('component_id' => 'root-en-cat1_3', 'visible' => true, 'name' => 'Foo3en', 'filename' => 'foo3en'), array('component_id' => 'root-en-cat1_4', 'visible' => true, 'name' => 'Foo4en', 'filename' => 'foo4en'), array('component_id' => 'root-en-cat1_5', 'visible' => true, 'name' => 'Foo5en', 'filename' => 'foo5en'), array('component_id' => 'root-en-cat1_6', 'visible' => true, 'name' => 'Foo6en', 'filename' => 'foo6en'), array('component_id' => 'root-en-cat1_7', 'visible' => true, 'name' => 'Foo7en', 'filename' => 'foo7en')); parent::__construct($config); }
public function __construct($config = array()) { $config['columns'] = array(); $config['primaryKey'] = 'id'; $config['data'] = array(array('id' => 1, 'component_id' => 'root-master_table', 'pos' => 0, 'visible' => 1, 'column1' => 'Abc', 'column2' => '1234', 'column3' => '234'), array('id' => 2, 'component_id' => 'root-master_table', 'pos' => 1, 'visible' => 1, 'column1' => 'Cde', 'column2' => '4321', 'column3' => '1234')); parent::__construct($config); }
public function __construct($config = array()) { $config['data'] = array(array('id' => 1), array('id' => 2), array('id' => 3)); $s = new Kwf_Model_Select(); $config['exprs'] = array('foo1' => new Kwf_Model_Select_Expr_Child_GroupConcat('Children', 'id'), 'foo2' => new Kwf_Model_Select_Expr_Child_GroupConcat('Children', 'id', ', '), 'foo3' => new Kwf_Model_Select_Expr_Child_GroupConcat('Children', 'id', ', ', $s, 'sort_field'), 'foo4' => new Kwf_Model_Select_Expr_Child_GroupConcat('Children', 'id', ', ', $s, array('field' => 'sort_field', 'direction' => 'DESC'))); parent::__construct($config); }
public function testUniqueAsciiGroupBy() { $f = new Kwf_Filter_Row_UniqueAscii('name'); $f->setGroupBy('group'); $model = new Kwf_Model_FnF(array('data' => array(array('id' => 1, 'name' => 'Name1', 'group' => 1, 'test' => 'name1'), array('id' => 2, 'name' => 'Name2', 'group' => 2, 'test' => 'name2')), 'filters' => array('test' => $f))); $row = $model->createRow(); $row->group = 1; $row->name = 'Name1'; $row->save(); $this->assertEquals('name1_1', $model->getRow(3)->test); $row = $model->createRow(); $row->group = 2; $row->name = 'Name1'; $row->save(); $this->assertEquals('name1', $model->getRow(4)->test); }
public function __construct($config = array()) { $config['columns'] = array('fullname', 'email', 'phone', 'content'); $config['namespace'] = 'favourites_model_session'; $config['primaryKey'] = 'fullname'; parent::__construct($config); }
public function _init() { $this->_referenceMap = array('Parent' => 'parent_id->Kwf_Model_FnF_ExprGroupConcat_Model'); $this->_columns = array('id', 'parent_id', 'sort_field', 'sort_field_2'); $this->_data = array(array('id' => 1, 'parent_id' => 1, 'sort_field' => 3, 'sort_field_2' => 'bbb'), array('id' => 2, 'parent_id' => 1, 'sort_field' => 1, 'sort_field_2' => 'aaa'), array('id' => 3, 'parent_id' => 2, 'sort_field' => 2, 'sort_field_2' => 'ccc')); parent::_init(); }
public function _init() { $this->_dependentModels['Childs'] = 'Kwf_Model_FnF_ParentExpr_ChildModel'; $this->_columns = array('id', 'foo'); $this->_data = array(array('id' => 1, 'foo' => 5), array('id' => 2, 'foo' => 7)); parent::_init(); }
public function _init() { $this->_referenceMap = array('Parent' => 'parent_id->Kwf_Model_FnF_ProxyFnFExtendedReference_ParentModel'); $this->_columns = array('id', 'parent_id', 'bar'); $this->_data = array(array('id' => 1, 'parent_id' => 1, 'bar' => 5), array('id' => 2, 'parent_id' => 2, 'bar' => 1), array('id' => 3, 'parent_id' => 1, 'bar' => 1)); parent::_init(); }
protected function _init() { parent::_init(); for ($i = 1; $i < 50; $i++) { $this->_data[] = array('id' => $i, 'name' => 'foo' . $i); } }
public function __construct($config = array()) { $config['namespace'] = 'listchildpages_teaser_pagemodel'; $config['primaryKey'] = 'id'; $config['data'] = array(array('id' => 400, 'pos' => 1, 'visible' => true, 'name' => 'name400', 'filename' => 'name400', 'custom_filename' => false, 'parent_id' => 'root', 'component' => 'listchild', 'is_home' => true, 'category' => 'main', 'hide' => false, 'parent_subroot_id' => 'root'), array('id' => 500, 'pos' => 1, 'visible' => true, 'name' => 'name500', 'filename' => 'name500', 'custom_filename' => false, 'parent_id' => 400, 'component' => 'empty', 'is_home' => false, 'category' => 'main', 'hide' => false, 'parent_subroot_id' => 'root'), array('id' => 501, 'pos' => 2, 'visible' => false, 'name' => 'name501', 'filename' => 'name501', 'custom_filename' => false, 'parent_id' => 400, 'component' => 'empty', 'is_home' => false, 'category' => 'main', 'hide' => false, 'parent_subroot_id' => 'root'), array('id' => 502, 'pos' => 3, 'visible' => true, 'name' => 'name502', 'filename' => 'name502', 'custom_filename' => false, 'parent_id' => 400, 'component' => 'empty', 'is_home' => false, 'category' => 'main', 'hide' => false, 'parent_subroot_id' => 'root'), array('id' => 401, 'pos' => 1, 'visible' => true, 'name' => 'name401', 'filename' => 'name401', 'custom_filename' => false, 'parent_id' => 'root', 'component' => 'listchildwithvisible', 'is_home' => false, 'category' => 'main', 'hide' => false, 'parent_subroot_id' => 'root'), array('id' => 600, 'pos' => 1, 'visible' => true, 'name' => 'name600', 'filename' => 'name600', 'custom_filename' => false, 'parent_id' => 401, 'component' => 'empty', 'is_home' => false, 'category' => 'main', 'hide' => false, 'parent_subroot_id' => 'root'), array('id' => 601, 'pos' => 2, 'visible' => false, 'name' => 'name601', 'filename' => 'name601', 'custom_filename' => false, 'parent_id' => 401, 'component' => 'empty', 'is_home' => false, 'category' => 'main', 'hide' => false, 'parent_subroot_id' => 'root'), array('id' => 602, 'pos' => 3, 'visible' => true, 'name' => 'name602', 'filename' => 'name602', 'custom_filename' => false, 'parent_id' => 401, 'component' => 'empty', 'is_home' => false, 'category' => 'main', 'hide' => false, 'parent_subroot_id' => 'root')); parent::__construct($config); }
protected function _init() { parent::_init(); for ($i = 1; $i <= 50; $i++) { $this->_data[] = array('component_id' => 'root-en_directory_' . $i, 'name' => 'footrl' . $i, 'visible' => true); } }
public function _init() { $this->_referenceMap = array('Parent' => 'parent_id->Kwf_Model_FnF_ParentExprDeletedFlag_ParentModel'); $this->_columns = array('id', 'parent_id', 'bar'); $this->_data = array(array('id' => 1, 'parent_id' => 1, 'bar' => 5), array('id' => 2, 'parent_id' => 2, 'bar' => 1), array('id' => 3, 'parent_id' => 1, 'bar' => 1)); parent::_init(); $this->_exprs['parent_foo'] = new Kwf_Model_Select_Expr_Parent('Parent', 'foo'); }
public function _init() { $this->_dependentModels['Childs'] = 'Kwf_Model_FnF_ParentExprDeletedFlag_ChildModel'; $this->_hasDeletedFlag = true; $this->_columns = array('id', 'foo', 'deleted'); $this->_data = array(array('id' => 1, 'foo' => 5, 'deleted' => true), array('id' => 2, 'foo' => 7, 'deleted' => false)); parent::_init(); }
public function __construct($config = array()) { $config['columns'] = array('id', 'component_id', 'user_id'); $config['namespace'] = 'favourites_model_session'; $config['primaryKey'] = 'id'; $config['data'] = array(array('id' => 1, 'component_id' => '2001_favourite', 'user_id' => 1), array('id' => 2, 'component_id' => '2002', 'user_id' => 1), array('id' => 4, 'component_id' => '2001_favourite', 'user_id' => 2)); parent::__construct($config); }
protected function _getRowByParentRow($parentRow) { $key = $parentRow ? $parentRow->getInternalId() : 0; if (!isset($this->_rows[$key])) { if (!$parentRow && $this->getIdTemplate()) { //tritt auf in Cards bei einer nicht aktiven card (da ist parentRow null) return null; } $id = $this->_getIdByParentRow($parentRow); $model = new Kwf_Model_FnF(); $this->_rows[$key] = $model->createRow(array('id' => $id)); } if ($this->_rows[$key] instanceof Kwf_Model_FnF_Row) { $this->_rows[$key]->id = $this->_getIdByParentRow($parentRow); } return $this->_rows[$key]; }
public function __construct(array $config = array()) { $config['uniqueIdentifier'] = 'unique'; $config['columns'] = array('id', 'sib_lastname'); $config['uniqueColumns'] = array('id'); $config['data'] = array(array('id' => 1, 'sib_lastname' => 'herbertsen')); parent::__construct($config); }
public function testBirthWithReference() { $today = date('Y-m-d'); $today = date('Y-m-d', strtotime("{$today} -1 year")); $eighteen = date("Y-m-d", strtotime("{$today} -17 year")); $tomorrow = date("Y-m-d", strtotime("{$today} +1 day")); $yesterday = date("Y-m-d", strtotime("{$today} - 1 day")); $newYearsEve = date('Y') - 1 . "-12-31"; $expectNYE = 0; $expectNY = 1; $realTomorrow = date("Y-m-d", strtotime("{$tomorrow} +1 year")); //if it is new Year's Eve the expected age for new Year = 2; if ($realTomorrow == date('Y') . '-12-31') { $expectNYE = 1; } //if it is new Year's Eve the expected age for new Year = 2; if (date('m-d') == '12-31') { $expectNY = 2; } $newYear = date('Y') - 1 . "-01-01"; $model = new Kwf_Model_FnF(array('columns' => array('id', 'birth'), 'data' => array(array('id' => 1, 'birth' => $eighteen), array('id' => 2, 'birth' => $today), array('id' => 3, 'birth' => $tomorrow), array('id' => 4, 'birth' => $yesterday), array('id' => 5, 'birth' => $newYearsEve), array('id' => 6, 'birth' => $newYear)), 'exprs' => array('age' => new Kwf_Model_Select_Expr_Date_Age('birth', new Kwf_Date($realTomorrow))))); $this->assertEquals($model->getRow(1)->age, 18); $this->assertEquals($model->getRow(2)->age, 1); $this->assertEquals($model->getRow(3)->age, 1); $this->assertEquals($model->getRow(4)->age, 1); $this->assertEquals($model->getRow(5)->age, $expectNYE); $this->assertEquals($model->getRow(6)->age, $expectNY); }
public function __construct($config = array()) { $config['columns'] = array('id', 'component_id', 'visible'); $config['namespace'] = 'listchildpages_teaser_teaserwithchild_model'; $config['primaryKey'] = 'component_id'; //'{component_id}-{id} $config['data'] = array(array('component_id' => '401-600', 'visible' => false), array('component_id' => '401-601', 'visible' => true), array('component_id' => '401-602', 'visible' => true)); parent::__construct($config); }
public function testNumberizeGroupBy() { $f = new Kwf_Filter_Row_AutoIncrement(); $f->setGroupBy('group'); $model = new Kwf_Model_FnF(array('data' => array(array('id' => 1, 'number' => 1, 'group' => 1, 'foo' => 'foo1'), array('id' => 2, 'number' => 1, 'group' => 2, 'foo' => 'foo2'), array('id' => 3, 'number' => 2, 'group' => 1, 'foo' => 'foo3')), 'filters' => array('number' => $f))); $row = $model->createRow(); $row->group = 2; $row->foo = 'foo4'; $row->save(); $this->assertEquals(2, $model->getRow(4)->number); $this->assertEquals(1, $model->getRow(2)->number); $this->assertEquals(1, $model->getRow(1)->number); $this->assertEquals(1, $model->getRow(2)->number); $model->getRow(2)->delete(); $this->assertEquals(1, $model->getRow(1)->number); $this->assertEquals(2, $model->getRow(3)->number); $this->assertEquals(2, $model->getRow(4)->number); }