protected function setUp() { $this->products = array(); $this->compositions = array(); // Setup tax and categories $taxCat = new TaxCat("Tax"); $tax = new Tax(null, "Tax", stdtimefstr("2001-01-01 00:00:00"), 0.1); $taxCat->addTax($tax); $taxCat->id = TaxesService::createCat($taxCat); $pdo = PDOBuilder::getPDO(); $id = CompositionsService::CAT_ID; $catCmp = new Category(null, "Compositions", false, 1); $sql = "INSERT INTO CATEGORIES (ID, NAME, PARENTID, DISPORDER, IMAGE) " . "VALUES (:id, :name, :pid, :order, null)"; $stmt = $pdo->prepare($sql); $stmt->bindParam(":name", $catCmp->label, \PDO::PARAM_STR); $stmt->bindParam(":pid", $catCmp->parentId, \PDO::PARAM_INT); $stmt->bindParam(":id", $id, \PDO::PARAM_INT); $stmt->bindParam(":order", $catCmp->dispOrder, \PDO::PARAM_INT); $stmt->execute(); $cat = new Category(null, "Category", false, 2); $cat->id = CategoriesService::createCat($cat); // Set up products $prd = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, true, 0.3, null, "12345", false, true, 0.2); $prd->id = ProductsService::create($prd, null); $this->products[] = $prd; $prd2 = new Product("REF2", "product2", 2.0, $cat->id, null, 3, $taxCat->id, true, false); $prd2->id = ProductsService::create($prd2, null); $this->products[] = $prd2; $cmp = new Composition("CMP", "composition", 1.0, $id, 1, $taxCat->id, true, true, 0.3, null, "12345", false, true, 0.2); $subgrp = new Subgroup(null, "Subgroup", 1, false); $subgrp->addProduct(new SubgroupProduct($prd->id, null, 1)); $subgrp->addProduct(new SubgroupProduct($prd2->id, null, 2)); $cmp->addGroup($subgrp); $cmp->id = CompositionsService::create($cmp, null, null); $this->compositions[] = $cmp; }
public function testHasFromRequireDev() { $this->assertTrue(\Composition::has('doctrine/common', '>2.0')); $this->assertTrue(\Composition::has('doctrine/common', '2.3.*')); $this->assertFalse(\Composition::has('doctrine/common', '2.2.*')); }
/** * Allow to manually set the project root dir. * * @param type $rootDir */ public static function setRootDir($rootDir) { self::$rootDir = $rootDir; }
include "../app/models/lesson_composer.php"; include "../app/models/lesson_composition.php"; include "../app/models/video.php"; // NO ACTION PROVIDED if (!isset($_GET['action'])) { send_error(); } // ACTIONS, OUR CONTROLLER switch ($_GET['action']) { case 'loadcomposers': $composer = new Composer(); $data = $composer->loadComposers(); send_json($data); break; case 'getnextcomposition': $composition = new Composition(); $data = $composition->getNextComposition(); send_json($data); break; default: send_error(); } // AUXILIAR function send_error() { send_json(array('success' => false)); } function send_json($data) { header('Content-Type: application/json'); echo json_encode($data);
private static function build($prd) { // Get the product $db = DB::get(); $compo = Composition::__build($prd['ID'], $prd['REFERENCE'], $prd['NAME'], $prd['PRICESELL'], $prd['CATEGORY'], $dpPrd['PROVIDER'], $prd['CATORDER'], $prd['TAXCAT'], $prd['PRODUCT'] != null, $db->readBool($prd['ISSCALE']), $prd['PRICEBUY'], $prd['ATTRIBUTESET_ID'], $prd['CODE'], $prd['IMAGE'] !== null, $db->readBool($prd['DISCOUNTENABLED']), $prd['DISCOUNTRATE']); // Get the subgroups $subgrpSrv = new SubgroupsService($compo->id); $compo->groups = $subgrpSrv->getAll(); return $compo; }