function testWhenRewritesDisabled_ShouldNotRewriteTitle() { $config = new Zend_Config(array('seo' => array('rewriteProductName' => false, 'globalRewrites' => true))); $product = $this->getProduct2($config); $product->addVafFit($this->vehicle->toValueArray()); $this->setRequestParams($this->vehicle->toValueArray()); $this->assertEquals('Widget', $product->getName(), 'when rewrites disabled, should not rewrite title'); }
function serviceCode() { $select = $this->getReadAdapter()->select()->from($this->wrappedVehicle->schema()->definitionTable(), array('service_code')); foreach ($this->toValueArray() as $key => $val) { $select->where($key . '_id = ?', $val); } $result = $this->query($select); return $result->fetchColumn(); }
function testWheelSizeShouldNotPrecedeVehicleForNonWheelProducts() { $product = $this->newWheelProduct(1); $product->addVafFit($this->vehicle->toValueArray()); $this->setRequestParams(array('lug_count' => '4', 'stud_spread' => '114.3')); $_SESSION = $this->vehicle->toValueArray(); return $this->markTestIncomplete(); //$this->assertEquals( array(1), $this->flexibleWheelSearch()->doGetProductIds(), 'wheel size should not precede vehicle for non wheel products' ); }
function testWhenRewritesDisabled_ShouldNotRewriteTitle2() { $config = new Zend_Config(array('seo' => array('rewriteProductName' => false))); $product = $this->getProduct2($config); $product->addVafFit($this->vehicle->toValueArray()); $this->setRequestParams($this->vehicle->toValueArray()); $product->setCurrentlySelectedFit(VF_Singleton::getInstance()->vehicleSelection()); $this->assertEquals('Widget', $product->getName(), 'when rewrites disabled, should not rewrite title'); }
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 vafUrl(VF_Vehicle $vehicle) { $params = http_build_query($vehicle->toValueArray()); if ($vehicle->getLeafValue()) { if ('/' == $this->getRequest()->getBasePath()) { return '/vaf/product/list?' . $params; } return $this->getRequest()->getBasePath() . '/vaf/product/list?' . $params; } return '?' . $params; }
function testSaveParenetheses() { $schema = VF_Schema::create('foo,bar'); $vehicle = VF_Vehicle::create($schema, array('foo' => 'valfoo', 'bar' => 'valbar')); $vehicle->save(); $vehicleExists = $this->vehicleExists(array('foo' => 'valfoo', 'bar' => 'valbar'), false, $schema); $this->assertTrue($vehicleExists, 'should find vehicles in different schema'); }
function testSaveParenetheses() { return $this->markTestIncomplete(); $schema = VF_Schema::create('foo,bar'); $vehicle = VF_Vehicle::create($schema, array('foo'=>'valfoo','bar'=>'valbar')); $vehicle->save(); $this->assertTrue($this->vehicleExists(array('foo'=>'valfoo','bar'=>'valbar')), 'should find vehicles in different schema' ); }
function main() { $schema = new VF_Schema(); $schemaGenerator = new VF_Schema_Generator(); $schemaGenerator->dropExistingTables(); $schemaGenerator->execute(array('make', 'model', 'year')); for ($i = 2000; $i <= 2010; $i++) { $vehicleParts = array('make' => 'Honda', 'model' => 'Civic', 'year' => $i); $vehicle = VF_Vehicle::create($schema, $vehicleParts); $vehicle->save(); echo "Created vehicle {$vehicle} \n"; } }
function saveAction() { $dataToSave = $this->requestLevels(); $vehiclesFinder = new \VF_Vehicle_Finder(new \VF_Schema()); $vehicle = $vehiclesFinder->findOneByLevelIds($dataToSave, \VF_Vehicle_Finder::INCLUDE_PARTIALS); if ($vehicle) { $dataToSave = $vehicle->toTitleArray(); } else { $dataToSave = array(); } $dataToSave[$this->params()->fromQuery('entity')] = $this->params()->fromQuery('title'); $vehicle = \VF_Vehicle::create(new \VF_Schema(), $dataToSave); $vehicle->save(); if (1 || $this->getRequest()->isXmlHttpRequest()) { echo $vehicle->getValue($this->params()->fromQuery('entity')); exit; } }
* @copyright Copyright (c) 2013 Vehicle Fits, llc * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ require_once '../config.default.php'; require_once(getenv('PHP_MAGE_PATH').'/app/code/local/Elite/Vaf/bootstrap-tests.php'); $schemaGenerator = new VF_Schema_Generator(); $schemaGenerator->dropExistingTables(); $schemaGenerator->execute(array('make','model type','year')); $schema = new VF_Schema(); $vehicle = VF_Vehicle::create( $schema, array( 'make' => 'Honda_Unique'.uniqid(), 'model type' => 'Civic', 'year' => '2002' )); $vehicle->save(); $values = $vehicle->toValueArray(); $mapping = new VF_Mapping( 1, $vehicle ); $mapping->save(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" href="../qunit/qunit.css" type="text/css"/>
* versions in the future. If you wish to customize Vehicle Fits for your * needs please refer to http://www.vehiclefits.com for more information. * @copyright Copyright (c) 2013 Vehicle Fits, llc * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ if (file_exists('../config.php')) { require_once '../config.php'; } else { require_once '../config.default.php'; } require_once getenv('PHP_MAGE_PATH') . '/app/code/local/Elite/Vaf/bootstrap-tests.php'; $schemaGenerator = new VF_Schema_Generator(); $schemaGenerator->dropExistingTables(); $schemaGenerator->execute(array('make', 'model', 'chassis', 'trim')); $schema = VF_Singleton::getInstance()->schema(); $vehicle = VF_Vehicle::create($schema, array('make' => 'Honda_Unique' . uniqid(), 'model' => 'Civic', 'chassis' => 'chassis', 'trim' => 'trim')); $vehicle->save(); $mapping = new VF_Mapping(1, $vehicle); $mapping->save(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" href="../qunit/qunit.css" type="text/css"/> </head> <body> <h1 id="qunit-header">Vehicle Fits - MMTC</h1> <h2 id="qunit-banner"></h2> <h2 id="qunit-userAgent"></h2> <ol id="qunit-tests">
function addPaintCode(VF_Vehicle $vehicle, Elite_Vafpaint_Model_Paint $paint) { $schema = VF_Singleton::getInstance()->schema(); $sql = sprintf("\n REPLACE INTO\n `elite_mapping_paint`\n ( `mapping_id`, `code`, `name`, `color` )\n VALUES\n ( %d, %s, %s, %s )\n ", (int) $vehicle->getId(), $this->getReadAdapter()->quote($paint->getCode()), $this->getReadAdapter()->quote($paint->getName()), $this->getReadAdapter()->quote($paint->getColor())); $this->query($sql); }
function merge_vehicle($slave_vehicle, $master_vehicle) { $titles = $slave_vehicle->toTitleArray(); $levelsToReplace = $this->getSchema()->getPrevLevelsIncluding($this->operatingGrain()); foreach ($levelsToReplace as $levelToReplace) { $titles[$levelToReplace] = $master_vehicle->getLevel($levelToReplace)->getTitle(); } $new_vehicle = VF_Vehicle::create($this->getSchema(), $titles); $new_vehicle->save(); $this->mergeFitments($slave_vehicle, $new_vehicle); }
if (file_exists('../config.php')) { require_once '../config.php'; } else { require_once '../config.default.php'; } require_once getenv('PHP_MAGE_PATH') . '/app/code/local/Elite/Vaf/bootstrap-tests.php'; file_put_contents(sys_get_temp_dir() . '/vf-ajax-tests', '1'); $schemaGenerator = new VF_Schema_Generator(); $schemaGenerator->dropExistingTables(); $schemaGenerator->execute(array('make', 'model', 'year')); $schema1 = new VF_Schema(1); $schema2 = VF_Schema::create('foo,bar'); $vehicle = VF_Vehicle::create($schema1, array('make' => 'Honda_Unique' . uniqid(), 'model' => 'Civic', 'year' => '2002')); $vehicle->save(); $values = $vehicle->toValueArray(); $vehicle2 = VF_Vehicle::create($schema2, array('foo' => 123, 'bar' => 456)); $vehicle2->save(); $values2 = $vehicle2->toValueArray(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" href="../qunit/qunit.css" type="text/css"/> <link rel="stylesheet" href="/skin/adminhtml/default/default/multiTree.css" type="text/css"/> </head> <body> <h1 id="qunit-header">VAF - Multi Tree</h1> <h2 id="qunit-banner"></h2> <h2 id="qunit-userAgent"></h2> <ol id="qunit-tests">
function buildDistinctQueryForVehicleEntityIdMappings(Zend_Db_Select $select, VF_Vehicle $vehicle) { $subSelect = $this->getReadAdapter()->select(); foreach ($this->schema()->getLevels() as $current_level) { $level = $vehicle->getLevel($current_level); if (!$level->getId()) { continue; } $subSelect->where(sprintf("%s = ?", $current_level), $level->getTitle()); } $select = $this->combineSubSelectIfWhereIsNotEmpty($select, $subSelect); return $select; }
require_once '../config.default.php'; } require_once getenv('PHP_MAGE_PATH') . '/app/code/local/Elite/Vaf/bootstrap-tests.php'; $schemaGenerator = new VF_Schema_Generator(); $schemaGenerator->dropExistingTables(); $schemaGenerator->execute(array('make', 'model', 'year')); $schema = VF_Singleton::getInstance()->schema(); $vehicle0 = VF_Vehicle::create($schema, array('make' => 'Ford', 'model' => 'F-150', 'year' => '2000')); $vehicle0->save(); $mapping = new VF_Mapping(1, $vehicle0); $mapping->save(); $vehicle1 = VF_Vehicle::create($schema, array('make' => 'Honda', 'model' => 'Civic', 'year' => '2002')); $vehicle1->save(); $mapping = new VF_Mapping(1, $vehicle1); $mapping->save(); $vehicle2 = VF_Vehicle::create($schema, array('make' => 'Honda', 'model' => 'Accord', 'year' => '2003')); $vehicle2->save(); $mapping = new VF_Mapping(1, $vehicle2); $mapping->save(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" href="../qunit/qunit.css" type="text/css"/> </head> <body> <h1 id="qunit-header">VAF - MMY</h1> <h2 id="qunit-banner"></h2> <h2 id="qunit-userAgent"></h2> <ol id="qunit-tests">
function getMappingId(VF_Vehicle $vehicle) { $schema = VF_Singleton::getInstance()->schema(); $select = $this->getReadAdapter()->select()->from($this->getSchema()->mappingsTable(), 'id')->where($schema->getLeafLevel() . '_id = ?', $vehicle->getLeafValue())->where('entity_id = ?', $this->getId()); return $select->query()->fetchColumn(); }
* @copyright Copyright (c) 2013 Vehicle Fits, llc * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ if (file_exists('../config.php')) { require_once '../config.php'; } else { require_once '../config.default.php'; } require_once getenv('PHP_MAGE_PATH') . '/app/code/local/Elite/Vaf/bootstrap-tests.php'; $schemaGenerator = new VF_Schema_Generator(); $schemaGenerator->dropExistingTables(); $schemaGenerator->execute(array('make', 'model', 'year')); $schema = new VF_Schema(); $vehicle = VF_Vehicle::create($schema, array('make' => 'Honda', 'model' => 'Civic', 'year' => '2001')); $vehicle->save(); $vehicle = VF_Vehicle::create($schema, array('make' => 'Honda', 'model' => 'Civic', 'year' => '2002')); $vehicle->save(); $values = $vehicle->toValueArray(); $mapping = new VF_Mapping(1, $vehicle); $mapping->save(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" href="../qunit/qunit.css" type="text/css"/> </head> <body> <h1 id="qunit-header">VAF - MMY</h1> <h2 id="qunit-banner"></h2> <h2 id="qunit-userAgent"></h2>
function vehicleSlug(VF_Vehicle $vehicle) { $config = $this->getConfig(); $rewriteLevels = $config->seo->rewriteLevels; if ($rewriteLevels) { $rewriteLevels = explode(',', $rewriteLevels); $slug = implode('~', $vehicle->toTitleArray($rewriteLevels)); } else { $slug = implode('~', $vehicle->toTitleArray()); } $slug = str_replace(' ', '-', $slug); $slug = str_replace('%7E', '~', urlencode($slug)); // url encode everything but tildes return $slug; }
function assertVehiclesSame(VF_Vehicle $vehicle1, VF_Vehicle $vehicle2) { $this->assertEquals($vehicle1->toValueArray(), $vehicle2->toValueArray()); }
function vehicleParams() { $params = $this->vehicle->levelIdsTruncateAfter($this->grain); return $params; }
/** @return Elite_Vafwheel_Model_BoltPattern_Single */ function boltPattern() { $r = $this->query(sprintf("\n SELECT lug_count, bolt_distance, offset\n FROM elite_definition_wheel\n WHERE leaf_id = %d\n ", (int) $this->wrappedVehicle->getId())); return $r->fetchObject(); }
function saveAction() { $schema = new VF_Schema($this->getRequest()->getParam('schema')); $dataToSave = $this->requestLevels(); $vehiclesFinder = new VF_Vehicle_Finder($schema); $vehicle = $vehiclesFinder->findOneByLevelIds($dataToSave, VF_Vehicle_Finder::INCLUDE_PARTIALS); if ($vehicle) { $dataToSave = $vehicle->toTitleArray(); } else { $dataToSave = array(); } $dataToSave[$this->getRequest()->getParam('entity')] = $this->getRequest()->getParam('title'); $vehicle = VF_Vehicle::create($schema, $dataToSave); $vehicle->save(); if ($this->getRequest()->isXmlHttpRequest()) { echo $vehicle->getValue($this->getRequest()->getParam('entity')); exit; } $this->doSave(); }
protected function createMMTC($makeTitle = 'test make', $modelTitle = 'test model', $trimTitle = 'test trim', $chassisTitle = 'test chassis') { $vehicle = VF_Vehicle::create(new VF_Schema(), array('make' => $makeTitle, 'model' => $modelTitle, 'trim' => $trimTitle, 'chassis' => $chassisTitle)); $vehicle->save(); return $vehicle; }