Example #1
0
 /**
  * test inserting a Product, editing it, and then updating it
  **/
 public function testUpdateValidProduct()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("product");
     // create a new Profile and insert to into mySQL
     $product = new Product(null, $this->vendor->getVendorId(), $this->VALID_description, $this->VALID_leadTime, $this->VALID_sku, $this->VALID_title);
     $product->insert($this->getPDO());
     // edit the Product and update it in mySQL
     $product->setLeadTime($this->VALID_leadTime2);
     $product->update($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoProducts = Product::getProductByProductId($this->getPDO(), $product->getProductId());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("product"));
     foreach ($pdoProducts as $pdoProduct) {
         $this->assertSame($pdoProduct->getVendorId(), $this->vendor->getVendorId());
         $this->assertSame($pdoProduct->getDescription(), $this->VALID_description);
         $this->assertSame($pdoProduct->getLeadTime(), $this->VALID_leadTime2);
         $this->assertSame($pdoProduct->getSku(), $this->VALID_sku);
         $this->assertSame($pdoProduct->getTitle(), $this->VALID_title);
     }
 }