function doSetUp() { $this->switchSchema('make,model,year'); $this->expectedDefinition = $this->createMMY(); $this->setRequestParams($this->expectedDefinition->toValueArray()); $this->sitemap = new Elite_Vafsitemap_Model_Sitemap_Product_Sub(VF_Singleton::getInstance()->getConfig()); }
function testCount1() { $sitemap = new Elite_Vafsitemap_Model_Sitemap_Vehicle(VF_Singleton::getInstance()->getConfig()); $vehicle = $this->createMMTC(); $this->insertMappingMMTC($vehicle); $this->assertEquals(1, $sitemap->vehicleCount()); }
function indexAction() { if (!VF_Singleton::getInstance()->getConfig()->seo->htmlSitemap) { return; } $this->loadLayoutAndBlock(); }
function listAction() { $helper = VF_Singleton::getInstance(); $helper->setRequest($this->getRequest()); $helper->storeFitInSession(); if (!$helper->vehicleSelection() || !$helper->getProductIds()) { return $this->redirectToHomePage(); } $this->myLoadLayout(); switch (VF_Singleton::getInstance()->getConfig()->homepagesearch->mode) { case 'grid': // set in layout.xml break; default: case 'group': // unset the grid block added from layout.xml $this->getLayout()->getBlock('content')->unsetChild('vaf_products'); $block = $this->createBlock('vaf/product_result_group', 'vaf_products'); $this->appendBlock($block); break; case 'category': // unset the grid block added from layout.xml $this->getLayout()->getBlock('content')->unsetChild('vaf_products'); $block = $this->createBlock('vaf/product_result_group2', 'vaf_products'); $this->appendBlock($block); break; case 'group3': // unset the grid block added from layout.xml $this->getLayout()->getBlock('content')->unsetChild('vaf_products'); $block = $this->createBlock('vaf/product_result_group3', 'vaf_products'); $this->appendBlock($block); break; } $this->renderLayout(); }
function testGetProductIDsWithSpace() { $vehicle2 = $this->createMMY('Ford', 'F 150', '2000'); $this->insertMappingMMY($vehicle2, 2); $this->setRequestParams($vehicle2->toTitleArray()); $this->assertEquals(array(2), VF_Singleton::getInstance()->getProductIds()); }
function testDefinitionsMMY() { $sitemap = new Elite_Vafsitemap_Model_Sitemap_Vehicle(VF_Singleton::getInstance()->getConfig()); $vehicles = $sitemap->getDefinitions(10); $this->assertTrue($vehicles[0] instanceof VF_Vehicle); $this->assertNotEquals(0, (int) $vehicles[0]->getLevel('year')->getId()); }
function getConfig() { if (!$this->config instanceof Zend_Config) { $this->config = VF_Singleton::getInstance()->getConfig(); } return $this->config; }
protected function block($config = array(), $request) { $block = new Elite_Vaf_Block_Search_SubmitTestSub(); $block->setConfig($this->config($config)); VF_Singleton::getInstance()->setRequest($request); return $block; }
function testShouldCreateSchemaOverCommandLine() { $command = __DIR__ . '/vf schema --force --levels="year,make,model"'; exec($command); $schema = VF_Singleton::getInstance()->schema(); $this->assertEquals(array('year', 'make', 'model'), $schema->getLevels(), 'should create default schema of MMY'); }
function getSelections() { $startTime = time(); $vehicle = VF_Singleton::getInstance()->vehicleSelection(); if (Mage::app()->getStore()->isAdmin()) { return $this->getData('selections'); } if (!$this->superProductFits($vehicle)) { return $this->getData('selections'); } $selections = $this->getData('selections'); if (!$selections) { return; } if ($vehicle && $vehicle->getLeafValue()) { $productIds = VF_Singleton::getInstance()->getProductIds(); $return = array(); foreach ($selections as $product) { if (in_array($product->getId(), $productIds)) { array_push($return, $product); } } return $return; } $endTime = time(); var_dump($endTime - $startTime); exit; return $selections; }
function testShouldClearFromSession() { $flexibleSearch = $this->flexibleWheeladapterSearch(array('wheel_stud_spread' => '114.3')); VF_Singleton::getInstance()->storeFitInSession(); $flexibleSearch = $this->flexibleWheeladapterSearch(array('wheel_stud_spread' => '0')); VF_Singleton::getInstance()->storeFitInSession(); $this->assertNull($this->flexibleWheeladapterSearch()->wheelSideStudSpread(), 'should clear wheel side stud spread from session'); }
function getSchema() { $schema = VF_Singleton::getInstance()->schema(); if (!is_null($this->getConfig())) { $schema->setConfig($this->getConfig()); } return $schema; }
function testShouldClearFromSession() { $flexibleSearch = $this->flexibleWheelSearch(array('stud_spread' => '5')); VF_Singleton::getInstance()->storeFitInSession(); $flexibleSearch = $this->flexibleWheelSearch(array('stud_spread' => '0')); VF_Singleton::getInstance()->storeFitInSession(); $this->assertEquals(0, $this->flexibleWheelSearch()->studSpread(), 'should clear stud spread from session'); }
function testShouldClearFromSession() { $flexibleSearch = $this->flexibleTireSearch(array('section_width' => '205', 'aspect_ratio' => '55', 'diameter' => '16')); VF_Singleton::getInstance()->storeFitInSession(); $flexibleSearch = $this->flexibleTireSearch(array('section_width' => '0', 'aspect_ratio' => '0', 'diameter' => '0')); VF_Singleton::getInstance()->storeFitInSession(); $this->assertNull($this->flexibleTireSearch()->diameter(), 'should clear diameter from session'); }
function testShouldClearFromSession() { $flexibleSearch = $this->flexibleWheeladapterSearch(array('wheel_lug_count' => '5')); VF_Singleton::getInstance()->storeFitInSession(); $flexibleSearch = $this->flexibleWheeladapterSearch(array('wheel_lug_count' => '0')); VF_Singleton::getInstance()->storeFitInSession(); $this->assertNull($this->flexibleWheeladapterSearch()->wheelSideLugCount(), 'should clear wheel side lug count from session'); }
function testShouldClearFromSession() { $flexibleSearch = $this->flexibleWheelSearch(array('lug_count' => '5')); VF_Singleton::getInstance()->storeFitInSession(); $flexibleSearch = $this->flexibleWheelSearch(array('lug_count' => '0')); VF_Singleton::getInstance()->storeFitInSession(); $this->assertEquals(0, $this->flexibleWheelSearch()->lugCount(), 'should clear lug count from session'); }
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 testDefinitions() { $sitemap = new Elite_Vafsitemap_Model_Sitemap_Vehicle(VF_Singleton::getInstance()->getConfig()); $vehicle = $this->createMMTC(); $this->insertMappingMMTC($vehicle); $vehicles = $sitemap->getDefinitions(); $this->assertTrue($vehicles[0] instanceof VF_Vehicle); $this->assertNotEquals(0, (int) $vehicles[0]->getLevel('chassis')->getId()); }
function run() { $schema = new VF_Schema(); $db = VF_Singleton::getInstance()->getReadAdapter(); foreach ($schema->getLevels() as $level) { $db->query('ALTER TABLE `elite_product_wheel` ADD `offset` FLOAT NOT NULL '); $db->query('ALTER TABLE `elite_definition_wheel` ADD `offset` FLOAT NOT NULL '); } }
function testShouldClearVehicleSelection() { $vehicle = $this->createVehicle(array('make' => 'Honda', 'model' => 'Civic', 'year' => '2000')); $this->setRequestParams($vehicle->toValueArray()); $this->assertEquals($vehicle->toValueArray(), VF_Singleton::getInstance()->vehicleSelection()->toValueArray(), 'should first select a vehicle'); $this->setRequestParams(array('section_width' => '205', 'aspect_ratio' => '55', 'diameter' => '16')); VF_Singleton::getInstance()->flexibleSearch()->doGetProductIds(); $this->assertNull(VF_Singleton::getInstance()->vehicleSelection()->getFirstVehicle(), 'should clear vehicle when searching on a tire size'); }
function doProduct($product) { $sitemap = new Elite_Vafsitemap_Model_Sitemap_Vehicle(VF_Singleton::getInstance()->getConfig()); $vehicles = $sitemap->getDefinitions(null, null, $product->getId()); foreach ($vehicles as $vehicle) { $product->setCurrentlySelectedFit($vehicle); fwrite($this->stream, $this->row($product, $vehicle)); } }
function testShouldClearVehicleSelection() { $vehicle = $this->createVehicle(array('make' => 'Honda', 'model' => 'Civic', 'year' => '2000')); $this->setRequestParams($vehicle->toValueArray()); $this->assertEquals($vehicle->toValueArray(), VF_Singleton::getInstance()->vehicleSelection()->toValueArray(), 'should first select a vehicle'); $this->setRequestParams(array('lug_count' => '5', 'stud_spread' => '114.3')); VF_Singleton::getInstance()->flexibleSearch()->doGetProductIds(); $this->assertNull(VF_Singleton::getInstance()->vehicleSelection()->getFirstVehicle(), 'should clear vehicle when searching on a wheel size'); }
/** Magento uses the "handle" of this action to load the block where the code lives */ function indexAction() { if (!VF_Singleton::getInstance()->getConfig()->seo->htmlSitemap) { return; } $this->loadLayout(); $this->_initLayoutMessages('checkout/session'); $this->_initLayoutMessages('tag/session'); $this->renderLayout(); }
function testShouldGetVehicleIdAndStoreInSession() { $request = $this->getSEORequest('http://example.com/vafsitemap/products/honda~civic~2000/'); $this->rewrite($request); $this->setRequest($request); VF_Singleton::getInstance()->getProductIds(); $this->assertEquals($this->definition->getLevel('make')->getId(), $_SESSION['make'], 'should look up the right ID#s from the vehicle string, and store in session'); $this->assertEquals($this->definition->getLevel('model')->getId(), $_SESSION['model'], 'should look up the right ID#s from the vehicle string, and store in session'); $this->assertEquals($this->definition->getLevel('year')->getId(), $_SESSION['year'], 'should look up the right ID#s from the vehicle string, and store in session'); }
function getProductRows() { $query = VF_Singleton::getInstance()->getReadAdapter()->select()->from($this->getProductTable(), array('entity_id', 'sku')); $rs = $query->query(); $ids = array(); while ($productRow = $rs->fetch()) { array_push($ids, $productRow); } return $ids; }
function jsAction() { header('Access-Control-Allow-Origin: *'); $processURL = $this->baseURL() . $this->url()->fromRoute('process') . '?'; \VF_Singleton::getInstance()->setProcessURL($processURL); header('Content-Type:application/x-javascript'); echo 'jQuery.noConflict();'; require_once 'VF/html/vafAjax.js.include.php'; exit; }
function testShouldSetSchema() { $schemaGenerator = new VF_Schema_Generator(); $schemaGenerator->dropExistingTables(); VF_Schema::$levels = null; $command = __DIR__ . '/vfmagento schema --force --levels="year,make,model"'; exec($command); $schema = VF_Singleton::getInstance()->schema(); $this->assertEquals(array('year', 'make', 'model'), $schema->getLevels(), 'should create default schema of MMY'); }
function testOneQueryAcrossInstances() { $this->getReadAdapter()->getProfiler()->clear(); $this->getReadAdapter()->getProfiler()->setEnabled(true); $schema = VF_Singleton::getInstance()->schema(); $schema->getLevels(); $schema = VF_Singleton::getInstance()->schema(); $schema->getLevels(); $queries = $this->getReadAdapter()->getProfiler()->getQueryProfiles(); $this->assertEquals(1, count($queries)); }
function testShouldSelectPartialVehicle() { $_SESSION['garage'] = new Elite_Vafgarage_Model_Garage(); $vehicle = $this->createVehicle(array('make' => 'Honda', 'model' => 'Civic', 'year' => 2000)); $requestParams = array('make' => $vehicle->getLevel('make')->getId(), 'model' => '', 'year' => ''); $this->setRequestParams($requestParams); VF_Singleton::getInstance()->storeFitInSession(); $block = new Elite_Vafgarage_design_garageTestSub(); $output = $block->_toHtml(); $this->assertRegExp('#' . $vehicle->getLevel('make')->getTitle() . '<#', $output, 'should render only partial vehicle name'); }
function testShouldGetVehicleIdAndStoreInSession() { $request = $this->getSEORequest('http://example.com/vafsitemap/products/honda~civic~2000/'); $config = new Zend_Config(array('seo' => array('rewriteLevels' => 'make,model,year'))); $this->rewrite($request, $config); $this->setRequest($request); VF_Singleton::getInstance()->getProductIds(); $this->assertEquals($this->definition->getLevel('make')->getId(), $_SESSION['make'], 'should look up the right ID#s from the vehicle string, and store in session'); $this->assertEquals($this->definition->getLevel('model')->getId(), $_SESSION['model'], 'should look up the right ID#s from the vehicle string, and store in session'); $this->assertEquals($this->definition->getLevel('year')->getId(), $_SESSION['year'], 'should look up the right ID#s from the vehicle string, and store in session'); $this->assertEquals(0, $_SESSION['engine'], 'should have partial vehicle selection'); }