function testShouldGetSchemaById()
 {
     $schema = VF_Schema::create('foo,bar');
     $schemaID = $schema->id();
     $new_schema = new VF_Schema($schemaID);
     $this->assertEquals(array('foo', 'bar'), $new_schema->getLevels(), 'should look up schema specified by ID passed to constructor');
 }
 function testShouldFindInSecondSchema()
 {
     $schema = VF_Schema::create('foo,bar');
     $vehicle = $this->createVehicle(array('foo' => '123', 'bar' => '456'), $schema);
     $found = $this->getFinder($schema)->findOneByLevelIds(array('foo' => $vehicle->getValue('foo')));
     $this->assertEquals($vehicle->getValue('foo'), $found->getValue('foo'), 'should find in second schema');
 }
 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');
 }
Esempio n. 4
0
 function testShouldSaveMappingInSecondSchema()
 {
     $schema = VF_Schema::create('foo,bar');
     $vehicle = $this->createVehicle(array('foo' => '123', 'bar' => '456'), $schema);
     $mapping = new VF_Mapping(1, $vehicle);
     $id = $mapping->save();
     $this->assertTrue($id > 0, 'should save mapping in second schema');
 }
 function testVehicleExists()
 {
     return $this->markTestIncomplete();
     
     $schema = VF_Schema::create('foo,bar');
     $finder = new VF_Vehicle_Finder($schema);
     $this->assertFalse($finder->vehicleExists(array('foo'=>'test','bar'=>'doesntexist')), 'vehicle should not exist');
 }
 function testSaveActionNewMultipleSchemas()
 {
     $schema = VF_Schema::create('foo,bar');
     $request = $this->getRequest(array('save' => self::ARBITRARY_STRING, 'title' => '123', 'entity' => 'foo', 'schema' => $schema->id()));
     $controller = $this->definitionsController($request);
     $controller->saveAction();
     $this->assertTrue($this->vehicleExists(array('foo' => '123'), true, $schema));
 }
 function testShouldGenerateMultipleSchemas()
 {
     $this->schemaGenerator()->execute(array('make', 'model', 'year'));
     $schema = VF_Schema::create('foo,bar');
     $expectedTable = 'elite_level_' . $schema->id() . '_foo';
     $tables = $this->getReadAdapter()->listTables();
     $this->assertTrue(in_array($expectedTable, $tables), 'should create table for new schema `elite_level_x_foo`');
 }
 function testShuoldListFromSecondSchema()
 {
     $schema = VF_Schema::create('foo,bar');
     $vehicle = $this->createVehicle(array('foo' => '123', 'bar' => '456'), $schema);
     $mapping = new VF_Mapping(1, $vehicle);
     $mapping->save();
     $foo = new VF_Level('foo', null, $schema);
     $actual = $foo->listInUse();
     $this->assertEquals('123', $actual[0], 'should list for level in 2nd schema "foo"');
 }
    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' );
    }
Esempio n. 10
0
 function testShouldListChildLevel_WhenCalledFromBackend()
 {
     $schema = VF_Schema::create('foo,bar');
     $vehicle = $this->createVehicle(array('foo' => '123', 'bar' => '456'), $schema);
     $mapping = new VF_Mapping(1, $vehicle);
     $mapping->save();
     ob_start();
     $_GET['requestLevel'] = 'bar';
     $_GET['foo'] = $vehicle->getValue('bar');
     $ajax = new VF_Ajax();
     $ajax->execute($schema);
     $actual = ob_get_clean();
     $this->assertEquals('<option value="' . $vehicle->getValue('bar') . '">456</option>', $actual, 'should list child levels from 2nd schema');
 }
Esempio n. 11
0
 function doMain($options)
 {
     if (!$options['levels']) {
         $this->askUserLevels();
     } else {
         $this->levels = $options['levels'];
     }
     if (!$options['add'] && !$options['force']) {
         $this->confirmTablesToDrop();
     }
     if (!$options['add']) {
         $this->generator->dropExistingTables();
     }
     if ($options['add']) {
         VF_Schema::create($options['levels']);
         $this->notifyUser(self::DONE);
     } else {
         $this->createTheNewTables();
     }
 }
 function testGetNewSchemasLevels()
 {
     $schema1 = VF_Schema::create('foo,bar');
     $schema2 = new VF_Schema;
     $this->assertEquals(array('foo','bar'),$schema1->getLevels(), 'should get new schemas levels');
 }
Esempio n. 13
0
 function testShouldListChildrenLevelsInSecondSchema()
 {
     $schema = VF_Schema::create('foo,bar');
     $vehicle = $this->createVehicle(array('foo' => '123', 'bar' => '456'), $schema);
     $bar = new VF_Level('bar', null, $schema);
     $actual = $bar->listAll($vehicle->getValue('foo'));
     $this->assertEquals('456', $actual[0]->getTitle(), 'should list children levels in 2nd schema');
 }
Esempio n. 14
0
 * @copyright  Copyright (c) 2013 Vehicle Fits, llc
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
session_start();
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>