/** * test grabbing unit of measure by the product id **/ public function testGetValidUnitOfMeasurementByProductId() { // create a new product 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()); $quantity = 5.9; // create a new product and insert to into mySQL $productLocation = new ProductLocation($this->location->getLocationId(), $product->getProductId(), $this->unitOfMeasure->getUnitId(), $quantity); $productLocation->insert($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $pdoUnitOfMeasureArray = Product::getUnitOfMeasureByProductId($this->getPDO(), $product->getProductId()); for ($i = 0; $i < count($pdoUnitOfMeasureArray); $i++) { if ($i === 0) { $this->assertSame($pdoUnitOfMeasureArray[$i]->getVendorId(), $this->vendor->getVendorId()); $this->assertSame($pdoUnitOfMeasureArray[$i]->getDescription(), $this->VALID_description); $this->assertSame($pdoUnitOfMeasureArray[$i]->getLeadTime(), $this->VALID_leadTime); $this->assertSame($pdoUnitOfMeasureArray[$i]->getSku(), $this->VALID_sku); $this->assertSame($pdoUnitOfMeasureArray[$i]->getTitle(), $this->VALID_title); } else { $this->assertSame($pdoUnitOfMeasureArray[$i]->getUnitId(), $this->unitOfMeasure->getUnitId()); $this->assertSame($pdoUnitOfMeasureArray[$i]->getUnitCode(), $this->unitOfMeasure->getUnitCode()); $this->assertSame($pdoUnitOfMeasureArray[$i]->getQuantity(), $this->unitOfMeasure->getQuantity()); } } }