/** * Export method * * @return void */ public function export() { $user = new Model\User(); $user->getExport($this->request->getPath(1), $this->request->getQuery('sort'), $this->request->getQuery('page')); if (isset($user->userRows[0])) { $userRows = $user->userRows; foreach ($userRows as $key => $value) { foreach ($value as $k => $v) { if (is_array($v)) { $userRows[$key]->{$k} = implode('|', $v); } } } \Pop\Data\Data::factory($userRows)->writeData($_SERVER['HTTP_HOST'] . '_' . $user->userType . '_' . date('Y-m-d') . '.csv', true, true); } else { Response::redirect($this->request->getBasePath() . '/index/' . $this->request->getPath(1)); } }
public function testWriteDataException() { $this->setExpectedException('Pop\\Data\\Exception'); $ary = array(array('name' => 'Test1', 'email' => '*****@*****.**'), array('name' => 'Test2', 'email' => '*****@*****.**')); $d = Data::factory($ary)->writeData(__DIR__ . '/../tmp/datatest.txt'); }