Ejemplo n.º 1
0
 public function testGetPrimaryKey()
 {
     $this->_client->expects($this->once())->method('getPrimaryKey')->will($this->returnValue('id2'));
     $model = new Kwf_Model_Service(array('client' => $this->_client));
     $pk = $model->getPrimaryKey();
     $this->assertEquals('id2', $pk);
 }
Ejemplo n.º 2
0
 public function testServiceFormatCsv()
 {
     $d = Zend_Registry::get('testDomain');
     $client = new Kwf_Srpc_Client(array('serverUrl' => "http://{$d}/kwf/test/kwf_model_db-with-connection_import-export_test/export", 'extraParams' => array('table' => $this->_tableName)));
     $model = new Kwf_Model_Service(array('client' => $client));
     $r = $model->getRow(1);
     $this->assertEquals(1, $r->id);
     $this->assertEquals('aaabbbccc', $r->foo);
     $data = $model->export(Kwf_Model_Interface::FORMAT_CSV);
     $model->deleteRows(array());
     $r = $model->getRow(1);
     $this->assertEquals(null, $r);
     $model->import(Kwf_Model_Interface::FORMAT_CSV, $data);
     $r = $model->getRow(1);
     $this->assertEquals(1, $r->id);
     $this->assertEquals('aaabbbccc', $r->foo);
     $this->assertEquals('abcd', $r->bar);
     $r = $model->getRow(2);
     $this->assertEquals(2, $r->id);
     $this->assertEquals('bam', $r->foo);
     $this->assertEquals('bum', $r->bar);
     $r = $model->getRow(3);
     $this->assertEquals(3, $r->id);
     $this->assertEquals('bäm', $r->foo);
     $this->assertEquals('büm', $r->bar);
 }
Ejemplo n.º 3
0
 public function testCreateSetId()
 {
     $this->_client->expects($this->once())->method('rowSave')->with(null, $this->equalTo(array('id' => 29, 'firstname' => 'Herbert', 'lastname' => 'Huber')))->will($this->returnValue(array('id' => 29, 'firstname' => 'Herbert', 'lastname' => 'Huber')));
     $model = new Kwf_Model_Service(array('client' => $this->_client));
     $row = $model->createRow();
     $row->id = 29;
     $row->firstname = 'Herbert';
     $row->lastname = 'Huber';
     $row->save();
     $this->assertEquals(29, $row->id);
     $this->assertEquals('Herbert', $row->firstname);
     $this->assertEquals('Huber', $row->lastname);
 }