Пример #1
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);
 }
Пример #2
0
 public function testGetRow()
 {
     $this->_client->expects($this->any())->method('getPrimaryKey')->will($this->returnValue('id'));
     $this->_client->expects($this->once())->method('getRows')->will($this->returnValue(array(array('id' => 3, 'firstname' => 'Max', 'lastname' => 'Muster'), array('id' => 13, 'firstname' => 'Hans', 'lastname' => 'Hermann'), array('id' => 4, 'firstname' => 'Foo', 'lastname' => 'Bar'))));
     $model = new Kwf_Model_Service(array('client' => $this->_client));
     $findRow = $model->getRow(3);
     $this->assertEquals(3, $findRow->id);
     $this->assertEquals('Max', $findRow->firstname);
     $this->assertEquals('Muster', $findRow->lastname);
 }