Пример #1
0
 /**
   Create a one-item sale. Requires sample data
   for item, batch types
 */
 public function unitTest($phpunit)
 {
     $this->u = array('0001878777132');
     //14.99
     $this->post_u_handler();
     $phpunit->assertEquals(1, count($this->upcs));
     $post = $this->post_u_view();
     $phpunit->assertNotEquals(0, strlen($post));
     $form = new \COREPOS\common\mvc\ValueContainer();
     $form->upc = $this->u;
     $form->preferredVendor = 0;
     $this->setForm($form);
     ob_start();
     $this->post_redoSRPs_handler();
     $json = ob_get_clean();
     $arr = json_decode($json, true);
     $phpunit->assertInternalType('array', $arr);
     $phpunit->assertEquals(1, count($arr));
     $phpunit->assertEquals($this->u[0], $arr[0]['upc']);
     $phpunit->assertEquals(0, $arr[0]['srp']);
     $form->startDate = date('Y-m-d');
     $form->endDate = date('Y-m-d');
     $form->batchName = 'Test BatchFromSearch';
     $form->batchType = 3;
     // price change batch means tags get created
     $form->batchOwner = 'IT';
     $form->price = array(1.99);
     $form->tagset = 1;
     $this->setForm($form);
     $this->post_createBatch_handler();
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $batch = new BatchesModel($dbc);
     $batch->batchName('Test BatchFromSearch');
     $phpunit->assertEquals(1, count($batch->find()));
     $sale = new BatchListModel($dbc);
     $sale->upc($this->u[0]);
     $sale->salePrice(1.99);
     $phpunit->assertEquals(1, count($sale->find()));
     $tag = new ShelftagsModel($dbc);
     $tag->id(1);
     $tag->upc($this->u[0]);
     $phpunit->assertEquals(true, $tag->load());
 }
Пример #2
0
 /**
   Create, update, and delete a batch
   Try each mode with and without an owner filter
 */
 public function unitTest($phpunit)
 {
     $get = $this->get_view();
     $phpunit->assertNotEquals(0, strlen($get));
     $this->connection->selectDB($this->config->get('OP_DB'));
     $model = new BatchesModel($this->connection);
     $this->newType = 1;
     $this->newName = 'Test BatchListPage';
     $this->newStart = date('Y-m-d 00:00:00');
     $this->newEnd = date('Y-m-d 00:00:00');
     $this->newOwner = 'IT';
     ob_start();
     $this->post_newType_newName_newStart_newEnd_newOwner_handler();
     ob_end_clean();
     $model->batchName($this->newName);
     $matches = $model->find();
     $phpunit->assertEquals(1, count($matches));
     $model->reset();
     $model->batchID($matches[0]->batchID());
     $phpunit->assertEquals(true, $model->load());
     $phpunit->assertEquals($this->newType, $model->batchType());
     $phpunit->assertEquals($this->newName, $model->batchName());
     $phpunit->assertEquals($this->newStart, $model->startDate());
     $phpunit->assertEquals($this->newEnd, $model->endDate());
     $phpunit->assertEquals($this->newOwner, $model->owner());
     $this->id = $model->batchID();
     $this->batchName = 'Change BatchListPage';
     $this->batchType = 2;
     $this->startDate = date('Y-m-d 00:00:00', strtotime('yesterday'));
     $this->endDate = $this->startDate;
     $this->owner = 'Admin';
     ob_start();
     $this->post_id_batchName_batchType_startDate_endDate_owner_handler();
     ob_end_clean();
     $model->reset();
     $model->batchID($this->id);
     $phpunit->assertEquals(true, $model->load());
     $phpunit->assertEquals($this->batchType, $model->batchType());
     $phpunit->assertEquals($this->batchName, $model->batchName());
     $phpunit->assertEquals($this->startDate, $model->startDate());
     $phpunit->assertEquals($this->endDate, $model->endDate());
     $phpunit->assertEquals($this->owner, $model->owner());
     $this->delete = 1;
     ob_start();
     $this->post_delete_id_handler();
     ob_end_clean();
     $model->reset();
     $model->batchID($this->id);
     $phpunit->assertEquals(false, $model->load());
     $modes = array('pending', 'current', 'historical', 'all');
     foreach ($modes as $m) {
         $get = $this->batchListDisplay('', $m, rand(0, 50));
         $phpunit->assertNotEquals(0, strlen($get));
         $get = $this->batchListDisplay('IT', $m, rand(0, 50));
         $phpunit->assertNotEquals(0, strlen($get));
     }
 }