/**
  * @param array $row
  * @param VF_Vehicle|boolean the vehicle, false if none (for example, when setting a product as universal)
  */
 function doImportRow($row, $vehicle)
 {
     $boltPattern = $this->getFieldValue('bolt_pattern', $row);
     $offset = $this->getFieldValue('offset', $row);
     $boltPattern = Elite_Vafwheel_Model_BoltPattern::create($boltPattern, $offset);
     $wheelDefinition = new Elite_Vafwheel_Model_Vehicle($vehicle);
     $wheelDefinition->addBoltPattern($boltPattern);
 }
	function testShouldDeleteBoltPatterns_WhenDeletingYear()
	{
		$vehicle = $this->createMMY('Honda','Civic','2000');
		$vehicle = new Elite_Vafwheel_Model_Vehicle($vehicle);
		$vehicle->addBoltPattern(Elite_Vafwheel_Model_BoltPattern::create('4x114.3'));
		
		$vehicle->getLevel('year')->delete();
		                                                                                                                
		$result = $this->query('select count(*) from elite_definition_wheel where leaf_id = '.$vehicle->getValue('year'));
		$this->assertEquals( 0, $result->fetchColumn(), 'should delete wheel record when deleting a year' );
	}
 /**
  * @expectedException Elite_Vaf_Model_Merge_Exception_IncompatibleVehicleAttribute
  */
 function testShouldPreventOperation()
 {
     $vehicle1 = $this->createMMY('Honda', 'Civic', '2000');
     $vehicle2 = $this->createMMY('Honda', 'Civic', '2001');
     $wheelVehicle1 = new Elite_Vafwheel_Model_Vehicle($vehicle1);
     $wheelVehicle1->save();
     $wheelVehicle1->addBoltPattern($this->boltPattern('4x114.3'));
     $wheelVehicle2 = new Elite_Vafwheel_Model_Vehicle($vehicle2);
     $wheelVehicle2->save();
     $wheelVehicle2->addBoltPattern($this->boltPattern('5x114'));
     $slaveLevels = array(array('year', $vehicle1), array('year', $vehicle2));
     $masterLevel = array('year', $vehicle2);
     $this->merge($slaveLevels, $masterLevel);
 }
 function testShouldDuplicateWheel()
 {
     $vehicle = $this->createMMY('Honda', 'Civic', '2000');
     $wheelVehicle = new Elite_Vafwheel_Model_Vehicle($vehicle);
     $wheelVehicle->save();
     $wheelVehicle->addBoltPattern($this->boltPattern('4x114.3'));
     $this->split($vehicle, 'year', array('2000', '2001'));
     $one = $this->vehicleFinder()->findOneByLevels(array('make' => 'Honda', 'model' => 'Civic', 'year' => '2000'));
     $wheelVehicle1 = new Elite_Vafwheel_Model_Vehicle($one);
     $two = $this->vehicleFinder()->findOneByLevels(array('make' => 'Honda', 'model' => 'Civic', 'year' => '2000'));
     $wheelVehicle2 = new Elite_Vafwheel_Model_Vehicle($two);
     $this->assertEquals(4, $wheelVehicle1->boltPattern()->lug_count, 'SPLIT Should copy wheel (bolt pattern) to each resultant vehicle.');
     $this->assertEquals(114.3, $wheelVehicle1->boltPattern()->bolt_distance, 'SPLIT Should copy wheel (bolt pattern) to each resultant vehicle.');
     $this->assertEquals(4, $wheelVehicle2->boltPattern()->lug_count, 'SPLIT Should copy wheel (bolt pattern) to each resultant vehicle.');
     $this->assertEquals(114.3, $wheelVehicle2->boltPattern()->bolt_distance, 'SPLIT Should copy wheel (bolt pattern) to each resultant vehicle.');
 }
 function testShouldNotAddWhenOffsetDoesntFit()
 {
     $wheelVehicle = new Elite_Vafwheel_Model_Vehicle($this->createMMY());
     $wheelVehicle->save();
     $wheelVehicle->addBoltPattern($this->boltPattern('4x114.3', 20));
     $wheelProduct = $this->newWheelProduct();
     $wheelProduct->setId(1);
     $wheelProduct->addBoltPattern($this->boltPattern('4x114.3', 42));
     $this->assertEquals(0, count($wheelProduct->getFits()), 'should not add when offset does not matche');
 }