Ejemplo n.º 1
0
    protected static function putTestContent()
    {
        QC::executeSQL('DROP TABLE IF EXISTS products');
        $storagePath = __DIR__ . '/storage/';
        $mo = ModelOperator::getInstance($storagePath);
        $mo->generateBasicStructure('Product');
        $ms = new ModelStructure('Product');
        $ms->addColumn('id_brand', array('type' => 'int(11) unsigned'));
        $ms->saveStructure();
        $mo->generateAllModelClasses();
        $mo->updateDBForAllModels();
        require_once $storagePath . 'bases/BaseProduct.php';
        require_once $storagePath . 'classes/Product.php';
        QC::create('products')->insert(array('title' => 'Macbook air'))->execute();
        $testProductFileContent = <<<TEXT
<?php

class ProductCustom extends BaseProduct {
    private \$_internalManufacturer = 'solve';
    public function getManufacturer() { return \$this->_internalManufacturer; }
    public function setManufacturer(\$value) { \$this->_internalManufacturer = \$value; return \$this; }
}
TEXT;
        file_put_contents($storagePath . 'classes/ProductCustom.php', $testProductFileContent);
        require_once $storagePath . 'classes/ProductCustom.php';
        $mo->setStructureForModel('ProductCustom', $mo->generateBasicStructure('Product', false), false);
    }
Ejemplo n.º 2
0
 protected static function putTestContent()
 {
     QC::executeSQL('DROP TABLE IF EXISTS products');
     $storagePath = __DIR__ . '/storage/';
     $mo = ModelOperator::getInstance($storagePath);
     $mo->generateBasicStructure('Product');
     $ms = new ModelStructure('Product');
     $ms->addColumn('info', array('type' => 'array'));
     $ms->saveStructure();
     $mo->generateAllModelClasses();
     $mo->updateDBForAllModels();
     require_once $storagePath . 'bases/BaseProduct.php';
     require_once $storagePath . 'classes/Product.php';
     QC::create('products')->insert(array('title' => 'Macbook air'))->execute();
 }