Esempio n. 1
0
 function setUp()
 {
     VF_Singleton::getInstance()->setReadAdapter(new VF_TestDbAdapter(array('dbname' => VAF_DB_NAME, 'username' => VAF_DB_USERNAME, 'password' => VAF_DB_PASSWORD)));
     $schemaGenerator = new VF_Schema_Generator();
     $schemaGenerator->dropExistingTables();
     VF_Schema::$levels = null;
 }
 function doSetUp()
 {
     $schemaGenerator = new VF_Schema_Generator();
     $schemaGenerator->dropExistingTables();
     $schemaGenerator->execute( array('year', 'make'=>array('global'=>true), 'model') );
     
     $this->startTransaction();
 }    
Esempio n. 3
0
 static function create($levels)
 {
     $schema = new VF_Schema();
     $schema->getReadAdapter()->insert('elite_schema', array('key' => 'levels', 'value' => $levels));
     $schema->setId($schema->getReadAdapter()->lastInsertId());
     $schemaGenerator = new VF_Schema_Generator();
     $schemaGenerator->execute(explode(',', $levels), false, $schema->id());
     return $schema;
 }
 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 = new VF_Schema();
     $this->assertEquals(array('year', 'make', 'model'), $schema->getLevels(), 'should create default schema of MMY');
 }
Esempio n. 5
0
 function setUp()
 {
     VF_Singleton::reset();
     VF_Singleton::getInstance(true);
     VF_Singleton::getInstance()->setRequest(new Zend_Controller_Request_Http());
     $database = new VF_TestDbAdapter(array('dbname' => VAF_DB_NAME, 'username' => VAF_DB_USERNAME, 'password' => VAF_DB_PASSWORD));
     VF_Singleton::getInstance()->setReadAdapter($database);
     $schemaGenerator = new VF_Schema_Generator();
     $schemaGenerator->dropExistingTables();
     $schemaGenerator->execute(array('make', 'model', 'year'));
     VF_Schema::reset();
 }
 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";
     }
 }
Esempio n. 7
0
 public function indexAction()
 {
     try {
         $schema = new \VF_Schema();
         $levels = $schema->getLevels();
     } catch (\Zend_Db_Statement_Exception $e) {
         $levels = array();
     }
     if ($this->getRequest()->isPost()) {
         $schemaGenerator = new \VF_Schema_Generator();
         $schemaGenerator->dropExistingTables();
         $schemaGenerator->execute(explode(",", $_POST['schema']));
         $this->flashMessenger()->setNamespace('success')->addMessage('Saved Schema');
     }
     return array('schema' => $levels);
 }
Esempio n. 8
0
 protected function switchSchema($levels, $force = false)
 {
     if (!$force) {
         try {
             $schema = new VF_Schema();
             if ($levels == implode(',', $schema->getLevels())) {
                 $this->startTransaction();
                 return;
             }
         } catch (Zend_Db_Statement_Mysqli_Exception $e) {
         } catch (Zend_Db_Statement_Exception $e) {
         }
     }
     $schemaGenerator = new VF_Schema_Generator();
     $schemaGenerator->dropExistingTables();
     $schemaGenerator->execute(explode(',', $levels));
     VF_Schema::reset();
     $this->startTransaction();
 }
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Vehicle Fits to newer
 * 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();
?>
<!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 - Install Test</h1>
    <h2 id="qunit-banner"></h2>
    <h2 id="qunit-userAgent"></h2>
    <ol id="qunit-tests">
    </ol>
    
 function doTearDown()
 {
     $schemaGenerator = new VF_Schema_Generator();
     $schemaGenerator->dropExistingTables();
 }
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Vehicle Fits to newer
 * 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)
 */
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 );
Esempio n. 12
0
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Vehicle Fits to newer
 * 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>
Esempio n. 13
0
        $generator = new Elite_Vafgarage_Model_Schema_Generator();
        $sql .= $generator->install();
    }
    foreach (explode(';', $sql) as $statement) {
        if (!trim($statement)) {
            continue;
        }
        try {
            $helper->getReadAdapter()->query($statement);
        } catch (Exception $e) {
            echo '<br /><span style="color:red;">ERROR: ' . $e->getMessage() . ' in SQL: ' . $statement . '</span>';
        }
    }
    echo '<br /><b style="color:green">Ok! Database created!</b>';
} else {
    if (isset($_REQUEST['levels']) && isset($_REQUEST['generateDb'])) {
        $generator = new VF_Schema_Generator();
        $sql = $generator->generator(explode(',', $_REQUEST['levels']));
        if (file_exists(ELITE_PATH . '/Vafpaint')) {
            $generator = new Elite_Vafpaint_Model_Schema_Generator();
            $sql .= $generator->install();
        }
        echo '<br /><textarea id="query_text" onClick="javascript:this.focus();this.select();" cols="100" rows="10">' . $sql . '</textarea>';
        echo '<br /><b style="color:green">Ok!</b></textarea>';
        echo '<br />Now copy and paste this into the SQL tab of your phpmyadmin. Drop any existing "elite_" tables first (but not before backing them up)<br />';
        echo '<script type="text/javascript" src="/skin/adminhtml/default/default/vf/jquery-1.7.1.min.js"></script>';
        echo '<script type="text/javascript">parent.jQuery("body").trigger("foo");</script>';
    }
}
?>
</fieldset>
 function testYearAsc()
 {
     $schemaGenerator = new VF_Schema_Generator();
     $schemaGenerator->setSorting('year', 'asc');
     $schema = new VF_Schema();
     $this->assertEquals('asc', $schema->getSorting('year'));
     $vehicle1 = $this->createMMY('Honda', 'Civic', '1999');
     $vehicle2 = $this->createMMY('Honda', 'Civic', '2000');
     $vehicle3 = $this->createMMY('Honda', 'Civic', '2001');
     $this->insertMappingMMY($vehicle1);
     $this->insertMappingMMY($vehicle2);
     $this->insertMappingMMY($vehicle3);
     $year = new VF_Level('year');
     $actual = $year->listInUse(array('model' => $vehicle1->getLevel('model')->getId()));
     $this->assertEquals("1999", $actual[0]->getTitle(), 'should return years, in ASC order');
     $this->assertEquals("2000", $actual[1]->getTitle(), 'should return years, in ASC order');
     $this->assertEquals("2001", $actual[2]->getTitle(), 'should return years, in ASC order');
 }
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Vehicle Fits to newer
 * 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)
 */
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(
    'year',
    'make' => array('global'=>true),
    'model'
));

$schema = new VF_Schema();

$vehicle = VF_Vehicle::create( $schema, array(
    'make' => 'Honda',
    'model' => 'Civic',
    'year' => '2002'
));
$vehicle->save();