コード例 #1
0
 /**
  * testNoteConcurrencyManagement
  * 
  * @see 0006278: concurrency conflict when saving product
  */
 public function testNoteConcurrencyManagement()
 {
     $savedProduct = $this->_addProduct(FALSE);
     $savedProduct['notes'][] = array('note' => 'another phpunit test note');
     $savedProduct = $this->_instance->saveProduct($savedProduct);
     $savedProduct['name'] = 'changed name';
     $savedProductNameChanged = $this->_instance->saveProduct($savedProduct);
     $savedProductNameChanged['name'] = 'PHPUnit test product';
     $savedProductNameChangedAgain = $this->_instance->saveProduct($savedProductNameChanged);
     $this->assertEquals('PHPUnit test product', $savedProductNameChangedAgain['name']);
 }
コード例 #2
0
 /**
  * test product json api
  *
  * @todo generalize this
  */
 public function testAddGetSearchDeleteProduct()
 {
     $product = $this->_getProduct();
     $productData = $product->toArray();
     // add note
     $note = array('note' => 'phpunit test note');
     $productData['notes'] = array($note);
     $savedProduct = $this->_instance->saveProduct($productData);
     $getProduct = $this->_instance->getProduct($savedProduct['id']);
     $searchProducts = $this->_instance->searchProducts($this->_getProductFilter(), '');
     //print_r($getProduct);
     // assertions
     $this->assertEquals($getProduct, $savedProduct);
     $this->assertTrue(count($getProduct['notes']) > 0, 'no notes found');
     $this->assertEquals($note['note'], $getProduct['notes'][0]['note']);
     $this->assertTrue($searchProducts['totalcount'] > 0);
     $this->assertEquals($product->description, $searchProducts['results'][0]['description']);
     // delete all
     $this->_instance->deleteProducts($savedProduct['id']);
     // check if delete worked
     $result = $this->_instance->searchProducts($this->_getProductFilter(), '');
     $this->assertEquals(0, $result['totalcount']);
 }