示例#1
0
 function testShouldReturnInjectedDatabase()
 {
     $database = new VF_TestDbAdapter(array('dbname' => VAF_DB_NAME, 'username' => VAF_DB_USERNAME, 'password' => VAF_DB_PASSWORD));
     $singleton = new VF_Singleton();
     $singleton->setReadAdapter($database);
     $this->assertSame($database, $singleton->getReadAdapter(), 'should return injected database');
 }
 function testNewRequest()
 {
     $singleton = new VF_Singleton();
     $request = $singleton->getRequest();
     // make sure it doesn't run Magento specific code here
     $this->assertNull($request);
     // we won't get here if it did.
 }
 function testSelection()
 {
     $vehicle = $this->createMMY(self::MAKE, self::MODEL, self::YEAR);
     $request = $this->getRequest($vehicle->toValueArray());
     $helper = new VF_Singleton();
     $helper->setRequest($request);
     $vehicle = $helper->vehicleSelection();
     $this->assertMMYTitlesEquals(self::MAKE, self::MODEL, self::YEAR, $vehicle);
 }
 function testCount1()
 {
     $sitemap = new Elite_Vafsitemap_Model_Sitemap_Vehicle(VF_Singleton::getInstance()->getConfig());
     $vehicle = $this->createMMTC();
     $this->insertMappingMMTC($vehicle);
     $this->assertEquals(1, $sitemap->vehicleCount());
 }
示例#5
0
 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');
 }
示例#6
0
 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 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();
 }
示例#8
0
 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());
 }
示例#9
0
 function getConfig()
 {
     if (!$this->config instanceof Zend_Config) {
         $this->config = VF_Singleton::getInstance()->getConfig();
     }
     return $this->config;
 }
 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());
 }
 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 indexAction()
 {
     if (!VF_Singleton::getInstance()->getConfig()->seo->htmlSitemap) {
         return;
     }
     $this->loadLayoutAndBlock();
 }
示例#13
0
 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');
 }
示例#15
0
 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');
 }
示例#16
0
 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 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('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');
 }
示例#19
0
 function getSchema()
 {
     $schema = VF_Singleton::getInstance()->schema();
     if (!is_null($this->getConfig())) {
         $schema->setConfig($this->getConfig());
     }
     return $schema;
 }
 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');
 }
 function testDeletingFits()
 {
     // create product & a fit
     $vehicle = $this->createMMY();
     $fit_id = $this->insertMappingMMY($vehicle, self::PRODUCT_ID);
     $product = $this->getProduct(self::PRODUCT_ID);
     $request = $this->getRequest(array('vaf-delete' => array('year-' . $fit_id)));
     // mock up an event and pass it to the SUT observer
     $event = $this->getMock('myEvent');
     $event->expects($this->any())->method('getControllerAction')->will($this->returnValue($this->getController($request)));
     Mage::register('current_product', $product);
     $observer = new Elite_Vaf_Model_Observer_Test();
     $observer->catalogProductEditAction($event);
     $request = $this->getRequest(array('make' => $vehicle->getLevel('make')->getId(), 'model' => $vehicle->getLevel('model')->getId(), 'year' => $vehicle->getLevel('year')->getId()));
     $helper = new VF_Singleton();
     $helper->setRequest($request);
     $this->assertEquals(array(0), $helper->getProductIds(), 'deleting fitments should result in there being no fitments');
 }
 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 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 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 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 ');
     }
 }
示例#26
0
 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));
     }
 }
示例#27
0
 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 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');
 }
示例#29
0
 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 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;
 }