예제 #1
0
 function productIds(VF_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;
 }
예제 #2
0
 function testShouldNotSelectAspectRatioWhenDisabled()
 {
     $vehicle = $this->createTireMMY('Honda', 'Civic', '2000');
     $vehicle->addTireSize(VF_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');
 }
예제 #3
0
 function testWhenSetTireSizeShouldBindVehicle()
 {
     $vehicle = $this->createTireMMY('Honda', 'Civic', '2000');
     $vehicle->addTireSize(VF_TireSize::create('205/55-16'));
     $product = $this->newTireProduct(self::ID);
     $product->setTireSize(VF_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');
 }
예제 #4
0
 /** @return VF_TireSize|boolean tire size, or false if formatting was invalid */
 function tireSize($row)
 {
     try {
         $tireSizeString = $this->getFieldValue('tire_size', $row);
         $tireSize = VF_TireSize::create($tireSizeString);
     } catch (VF_TireSize_InvalidFormatException $e) {
         return false;
     }
     return $tireSize;
 }
 function testWhenSetTireSizeShouldBindVehicle()
 {
     $vehicle = $this->createTireMMY('Honda', 'Civic', '2000');
     $vehicle->addTireSize(VF_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');
 }
예제 #6
0
 /**
  * @expectedException Elite_Vaf_Model_Merge_Exception_IncompatibleVehicleAttribute
  */
 function testShouldPreventOperation3()
 {
     $vehicle1 = $this->createTireMMY('Honda', 'Civic', '2000');
     $vehicle1->addTireSize(VF_TireSize::create('205/55-16'));
     $vehicle2 = $this->createTireMMY('Honda', 'Civic', '2001');
     $vehicle2->addTireSize(VF_TireSize::create('204/55-16'));
     $slaveLevels = array(array('year', $vehicle1->vehicle()), array('year', $vehicle2->vehicle()));
     $masterLevel = array('year', $vehicle2->vehicle());
     $this->merge($slaveLevels, $masterLevel);
 }
예제 #7
0
 function addTireSize(VF_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()));
 }
예제 #8
0
 function testShouldDuplicateTire()
 {
     $vehicle = $this->createMMY('Honda', 'Civic', '2000');
     $tireSize = VF_TireSize::create('205/55-16');
     $tireVehicle = new VF_Tire_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 VF_Tire_Vehicle($one);
     $two = $this->vehicleFinder()->findOneByLevels(array('make' => 'Honda', 'model' => 'Civic', 'year' => '2000'));
     $tireVehicle2 = new VF_Tire_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.');
 }
예제 #9
0
 function testDiameter()
 {
     $tireSize = new VF_TireSize(null, null, 16);
     $this->assertEquals(16, $tireSize->diameter(), 'tire size has a diameter');
 }
예제 #10
0
 /**
  * @expectedException VF_TireSize_InvalidFormatException
  */
 function testShouldThrowExceptionForMissingOutsideDiameter()
 {
     $tireSize = VF_TireSize::create('205/55-');
 }