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 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 testDefaultValues()
 {
     $fnf = new Kwf_Model_FnF(array('uniqueIdentifier' => 'unique', 'default' => array('foo' => 'defaultFoo')));
     $proxyModel = new Kwf_Model_ProxyCache(array('proxyModel' => $fnf, 'cacheSettings' => array(array('index' => array('id'), 'columns' => array('de')))));
     $row = $fnf->createRow();
     $this->assertEquals('defaultFoo', $row->foo);
     $row = $proxyModel->createRow();
     $this->assertEquals('defaultFoo', $row->foo);
 }
 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 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 testNumberizeGroupBy()
 {
     $f = new Kwf_Filter_Row_Numberize();
     $f->setGroupBy('group');
     $model = new Kwf_Model_FnF(array('data' => array(array('id' => 1, 'pos' => 1, 'group' => 1, 'foo' => 'foo1'), array('id' => 2, 'pos' => 1, 'group' => 2, 'foo' => 'foo2'), array('id' => 3, 'pos' => 2, 'group' => 1, 'foo' => 'foo3')), 'filters' => array('pos' => $f)));
     $row = $model->createRow();
     $row->pos = 1;
     $row->group = 2;
     $row->foo = 'foo4';
     $row->save();
     $this->assertEquals(1, $model->getRow(4)->pos);
     $this->assertEquals(2, $model->getRow(2)->pos);
     $this->assertEquals(1, $model->getRow(1)->pos);
     $this->assertEquals(2, $model->getRow(2)->pos);
 }
 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 testDefaultValues()
 {
     $model = new Kwf_Model_FnF(array('default' => array('foo' => 'defaultFoo')));
     $row = $model->createRow();
     $this->assertEquals('defaultFoo', $row->foo);
 }
Beispiel #10
0
 public function testDirtyColumnsOnCreateRow()
 {
     $model = new Kwf_Model_FnF(array('columns' => array('id', 'foo', 'data'), 'siblingModels' => array(new Kwf_Model_Field_FieldModel(array('fieldName' => 'data')))));
     $row = $model->createRow(array('id' => 2, 'foo' => 'bar2', 'blub' => 'blub2'));
     $this->assertEquals($row->getDirtyColumns(), array('id', 'foo', 'blub'));
 }