function productIds(Elite_Vaftire_Model_TireSize $tireSize, $tireType = null) { $select = $this->getReadAdapter()->select()->from('elite_product_tire', 'distinct(entity_id) entity_id')->where('section_width = ?', $tireSize->sectionWidth())->where('aspect_ratio = ?', $tireSize->aspectRatio())->where('diameter = ?', $tireSize->diameter()); if (!is_null($tireType)) { $select->where('tire_type = ?', $tireType); } $result = $select->query(); $return = array(); while ($row = $result->fetch()) { array_push($return, $row['entity_id']); } return $return; }
function testShouldNotSelectAspectRatioWhenDisabled() { $vehicle = $this->createTireMMY('Honda', 'Civic', '2000'); $vehicle->addTireSize(Elite_Vaftire_Model_TireSize::create('205/55-16')); $search = $this->flexibleTireSearch($vehicle->toValueArray()); $search->setConfig(new Zend_Config(array('tire' => array('populateWhenSelectVehicle' => '')))); $this->assertNull($search->aspectRatio(), 'should not preselect aspect ratio when selecting vehicle'); }
function testWhenSetTireSizeShouldBindVehicle() { $vehicle = $this->createTireMMY('Honda', 'Civic', '2000'); $vehicle->addTireSize(Elite_Vaftire_Model_TireSize::create('205/55-16')); $product = $this->newTireProduct(self::ID); $product->setTireSize(Elite_Vaftire_Model_TireSize::create('205/55-16')); $tireProduct = $this->newTireProduct(self::ID); $this->assertEquals(1, count($tireProduct->getFits()), 'should add vehicles for a product via its tire size'); }
function testWhenSetTireSizeShouldBindVehicle() { $vehicle = $this->createTireMMY('Honda', 'Civic', '2000'); $vehicle->addTireSize(Elite_Vaftire_Model_TireSize::create('205/55-16')); $product = $this->newProduct(self::ID); $this->setRequestParams(array('section_width' => '205', 'aspect_ratio' => '55', 'diameter' => 16)); $this->bindTireSize($product); $tireProduct = $this->newTireProduct(self::ID); $this->assertEquals(1, count($tireProduct->getFits()), 'should add vehicles for a product via its tire size'); }
/** @return Elite_Vaftire_Model_TireSize|boolean tire size, or false if formatting was invalid */ function tireSize($row) { try { $tireSizeString = $this->getFieldValue('tire_size', $row); $tireSize = Elite_Vaftire_Model_TireSize::create($tireSizeString); } catch (Elite_Vaftire_Model_TireSize_InvalidFormatException $e) { return false; } return $tireSize; }
/** * @expectedException Elite_Vaf_Model_Merge_Exception_IncompatibleVehicleAttribute */ function testShouldPreventOperation3() { $vehicle1 = $this->createTireMMY('Honda', 'Civic', '2000'); $vehicle1->addTireSize(Elite_Vaftire_Model_TireSize::create('205/55-16')); $vehicle2 = $this->createTireMMY('Honda', 'Civic', '2001'); $vehicle2->addTireSize(Elite_Vaftire_Model_TireSize::create('204/55-16')); $slaveLevels = array(array('year', $vehicle1->vehicle()), array('year', $vehicle2->vehicle())); $masterLevel = array('year', $vehicle2->vehicle()); $this->merge($slaveLevels, $masterLevel); }
function addTireSize(Elite_Vaftire_Model_TireSize $tireSize) { $select = $this->getReadAdapter()->select()->from('elite_vehicle_tire')->where('leaf_id = ?', (int) $this->wrappedVehicle->getLeafValue())->where('section_width = ?', (int) $tireSize->sectionWidth())->where('aspect_ratio = ?', (int) $tireSize->aspectRatio())->where('diameter = ?', (int) $tireSize->diameter()); $result = $select->query(); if ($result->fetchColumn()) { return; } $this->getReadAdapter()->insert('elite_vehicle_tire', array('leaf_id' => (int) $this->wrappedVehicle->getLeafValue(), 'section_width' => $tireSize->sectionWidth(), 'aspect_ratio' => $tireSize->aspectRatio(), 'diameter' => $tireSize->diameter())); }
function testShouldDuplicateTire() { $vehicle = $this->createMMY('Honda', 'Civic', '2000'); $tireSize = Elite_Vaftire_Model_TireSize::create('205/55-16'); $tireVehicle = new Elite_Vaftire_Model_Vehicle($vehicle); $tireVehicle->save(); $tireVehicle->addTireSize($tireSize); $this->split($vehicle, 'year', array('2000', '2001')); $one = $this->vehicleFinder()->findOneByLevels(array('make' => 'Honda', 'model' => 'Civic', 'year' => '2000')); $tireVehicle1 = new Elite_Vaftire_Model_Vehicle($one); $two = $this->vehicleFinder()->findOneByLevels(array('make' => 'Honda', 'model' => 'Civic', 'year' => '2000')); $tireVehicle2 = new Elite_Vaftire_Model_Vehicle($two); $one = $tireVehicle1->tireSize(); $two = $tireVehicle2->tireSize(); $this->assertEquals($tireSize, $one[0], 'SPLIT Should copy tire size to each resultant vehicle.'); $this->assertEquals($tireSize, $two[0], 'SPLIT Should copy tire size to each resultant vehicle.'); }
/** * @expectedException Elite_Vaftire_Model_TireSize_InvalidFormatException */ function testShouldThrowExceptionForMissingOutsideDiameter() { $tireSize = Elite_Vaftire_Model_TireSize::create('205/55-'); }
function testDiameter() { $tireSize = new Elite_Vaftire_Model_TireSize(null, null, 16); $this->assertEquals(16, $tireSize->diameter(), 'tire size has a diameter'); }