public function testDeleteLine($page, $phpunit) { $form = new \COREPOS\common\mvc\ValueContainer(); $form->_method = 'post'; $form->type = 'receiptHeader'; $form->id = array(0); $form->line = array('TEST CHANGED LINE'); $form->del = array(0); $post = $this->runRESTfulPage($page, $form); $model = new CustomReceiptModel($this->connection); $model->type($form->type); $model->text($form->line[0]); $phpunit->assertEquals(0, count($model->find())); }
protected function post_id_line_type_handler() { $this->connection->selectDB($this->config->get('OP_DB')); $model = new CustomReceiptModel($this->connection); $model->type($this->type); try { $delete = $this->form->del; } catch (Exception $ex) { $delete = array(); } $currentID = 0; for ($i = 0; $i < count($this->id); $i++) { $postedID = $this->id[$i]; $line = $this->line[$i]; if (!in_array($postedID, $delete)) { $model->seq($currentID); $model->text($line); $model->save(); $currentID++; } } try { $new = $this->form->newLine; if (!empty($new)) { $model->seq($currentID); $model->text($new); $model->save(); $currentID++; } } catch (Exception $ex) { } $trimP = $this->connection->prepare(' DELETE FROM customReceipt WHERE type=? AND seq >= ? '); $this->connection->execute($trimP, array($this->type, $currentID)); return $this->get_type_handler(); }