protected function setUp() { $this->currencies = array(); $srv = new CurrenciesService(); $euro = new Currency("Euro", "€", ",", ".", "#,##0.00\$", 1, true, true); $doll = new Currency("Dollar", "\$", ".", ",", "\$0#,##0.00", 1.25, false, true); $yen = new Currency("Yen", "Y", " ", " ", "#\$", 120, false, false); $euro->id = $srv->create($euro); $doll->id = $srv->create($doll); $yen->id = $srv->create($yen); $this->currencies[] = $euro; $this->currencies[] = $doll; $this->currencies[] = $yen; }
protected function setUp() { $locSrv = new LocationsService(); $location = new Location("Location"); $location->id = $locSrv->create($location); $cashRegSrv = new CashRegistersService(); $cashReg = new CashRegister("CashReg", $location->id, 1); $cashRegId = $cashRegSrv->create($cashReg); // Create a cash session $srv = new CashesService(); $cash = $srv->add($cashRegId); $this->cashId = $cash->id; $srv = new CurrenciesService(); $eur = new Currency("Eur", "€", ",", ".", "#,##0.00\$", 1, true, false); $this->currencyId = $srv->create($eur); }
protected function setUp() { // Attribute set $set = new AttributeSet("set"); $attr = new Attribute("attr", 1); $val = new AttributeValue("value"); $attr->id = AttributesService::createAttribute($attr); $val->id = AttributesService::createValue($val, $attr->id); $attr->addValue($val); $set->addAttribute($attr); $set->id = AttributesService::createSet($set); // Product, tax and category $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); $taxCat2 = new TaxCat("Tax2"); $tax2 = new Tax(null, "Tax2", stdtimefstr("2001-01-01 00:00:00"), 0.2); $taxCat2->addTax($tax2); $taxCat2->id = TaxesService::createCat($taxCat2); $pdo = PDOBuilder::getPDO(); $stmt = $pdo->prepare("INSERT INTO CATEGORIES (ID, NAME) " . "VALUES (:id, :name)"); $stmt->execute(array(":id" => "-1", ":name" => "Refill")); $cat = new Category(null, "Category", false, 1); $cat->id = CategoriesService::createCat($cat); $prd = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, false, 0.5, $set->id); $prd->id = ProductsService::create($prd); $prd2 = new Product("REF2", "product2", 2.0, $cat->id, null, 1, $taxCat2->id, true, false, 0.5, null); $prd2->id = ProductsService::create($prd2); $prdRefill = new Product("REFILL", "Refill", 1.0, "-1", null, 1, $taxCat->id, true, false); $prdRefill->id = ProductsService::create($prdRefill); // Tariff area $srvArea = new TariffAreasService(); $area = new TariffArea("area", 1); $area->addPrice($prd->id, 0.8); $area->id = $srvArea->create($area); $this->areaId = $area->id; // Customer $srvCust = new CustomersService(); $cust = new Customer(1, "Cust", "It's me", "card", null, null, 50.0, 10.0, 5.0, stdtimefstr("2012-01-01 00:00:00"), "It's", "me", "*****@*****.**", "012345", "23456", "11111", "Address1", "Address2", "59000", "City", "Region", "France", "Note", true); $cust->id = $srvCust->create($cust); $this->custId = $cust->id; // Location $locSrv = new LocationsService(); $loc = new Location("Location"); $loc->id = $locSrv->create($loc); $this->locationId = $loc->id; // Cash register $srvCashReg = new CashRegistersService(); $cashReg = new CashRegister("Cash", $loc->id, 1); $cashReg->id = $srvCashReg->create($cashReg); // Cash $srvCash = new CashesService(); $cash = $srvCash->add($cashReg->id); $cash->openDate = stdtimefstr("2000-02-02 02:02:02"); $srvCash->update($cash); $this->cashId = $cash->id; // User $srvUsers = new UsersService(); $user = new User("User", null, null, "0", true, false); $user->id = $srvUsers->create($user); // Currency $curr = new Currency("Eur", "€", ",", ".", "#,##0.00\$", 1, true, false); $srvCurr = new CurrenciesService(); $curr->id = $srvCurr->create($curr); // Discount profile $profSrv = new DiscountProfilesService(); $prof = new DiscountProfile("Profile", 0.1); $prof->id = $profSrv->create($prof); $this->discountProfilId = $prof->id; // Ticket $tkt1 = array("date" => stdtimefstr("2012-01-01 00:00:00"), "userId" => $user->id, "customerId" => null, "type" => Ticket::TYPE_SELL, "custCount" => 3, "tariffAreaId" => null, "discountRate" => 0.0, "discountProfileId" => null, "payments" => array(array("type" => "cash", "amount" => 10, "currencyId" => $curr->id, "currencyAmount" => 12)), "lines" => array(array("dispOrder" => 1, "productId" => $prd->id, "taxId" => $tax->id, "attributes" => null, "quantity" => 1.0, "price" => 10.0, "discountRate" => 0.0))); $jsAttr = array("attributeSetId" => $set->id, "values" => array(array("id" => $attr->id, "value" => "value"))); $tkt2 = array("date" => stdtimefstr("2012-01-01 00:00:00"), "userId" => $user->id, "customerId" => null, "type" => Ticket::TYPE_SELL, "custCount" => 3, "tariffAreaId" => null, "discountRate" => 0.25, "discountProfileId" => $prof->id, "payments" => array(array("type" => "cash", "amount" => 10, "currencyId" => $curr->id, "currencyAmount" => 12)), "lines" => array(array("dispOrder" => 1, "productId" => $prd->id, "taxId" => $tax->id, "attributes" => $jsAttr, "quantity" => 1.0, "price" => 10.0, "discountRate" => 0.25))); $this->jsTicket1 = json_encode($tkt1); $this->jsTicket2 = json_encode($tkt2); }
/** @depends testUpdate */ public function testUpdateMain() { $srv = new CurrenciesService(); $eur = new Currency("Eur", "€", ",", ".", "#,##0.00\$", 1, true, true); $eur->id = $srv->create($eur); $yen = new Currency("Yen", "Y", " ", " ", "#\$", 120, false, false); $yen->id = $srv->create($yen); $yen->isMain = true; $this->assertTrue($srv->update($yen)); $eurRead = $srv->get($eur->id); $yenRead = $srv->get($yen->id); $this->assertTrue($yenRead->isMain, "Main not set"); $this->assertFalse($eurRead->isMain, "Old main not unset"); }
protected function setUp() { // Attribute set $set = new AttributeSet("set"); $attr = new Attribute("attr", 1); $val = new AttributeValue("value"); $attr->id = AttributesService::createAttribute($attr); $val->id = AttributesService::createValue($val, $attr->id); $attr->addValue($val); $this->attr = $attr; $set->addAttribute($attr); $set->id = AttributesService::createSet($set); $this->attrSet = $set; // Product, tax and category $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); $taxCat2 = new TaxCat("Tax2"); $tax2 = new Tax(null, "Tax2", stdtimefstr("2001-01-01 00:00:00"), 0.2); $taxCat2->addTax($tax2); $taxCat2->id = TaxesService::createCat($taxCat2); $this->tax = $taxCat->taxes[0]; $this->tax2 = $taxCat2->taxes[0]; $pdo = PDOBuilder::getPDO(); $stmt = $pdo->prepare("INSERT INTO CATEGORIES (ID, NAME) " . "VALUES (:id, :name)"); $stmt->execute(array(":id" => "-1", ":name" => "Refill")); $cat = new Category(null, "Category", false, 1); $cat->id = CategoriesService::createCat($cat); $prd = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, false, 0.5, $set->id); $prd->id = ProductsService::create($prd); $this->prd = $prd; $prd2 = new Product("REF2", "product2", 2.0, $cat->id, null, 1, $taxCat2->id, true, false, 0.5, null); $prd2->id = ProductsService::create($prd2); $prdRefill = new Product("REFILL", "Refill", 1.0, "-1", null, 1, $taxCat->id, true, false); $prdRefill->id = ProductsService::create($prdRefill); $this->prd = $prd; $this->prd2 = $prd2; $this->prdRefill = $prdRefill; // Tariff area $srvArea = new TariffAreasService(); $area = new TariffArea("area", 1); $area->addPrice($this->prd->id, 0.8); $area->id = $srvArea->create($area); $this->area = $area; // Discount profile $srvProfile = new DiscountProfilesService(); $profile = new DiscountProfile("Discount profile", 1.0); $profile->id = $srvProfile->create($profile); $this->discountProfile = $profile; // Customer $srvCust = new CustomersService(); $cust = new Customer(1, "Cust", "It's me", "card", null, null, 50.0, 10.0, 5.0, stdtimefstr("2012-01-01 00:00:00"), "It's", "me", "*****@*****.**", "012345", "23456", "11111", "Address1", "Address2", "59000", "City", "Region", "France", "Note", true); $cust->id = $srvCust->create($cust); $this->customer = $cust; // Location $locSrv = new LocationsService(); $loc = new Location("Location"); $loc->id = $locSrv->create($loc); $this->location = $loc; // Cash $srvCashReg = new CashRegistersService(); $cashReg = new CashRegister("CashReg", $loc->id, 1); $cashReg->id = $srvCashReg->create($cashReg); $srvCash = new CashesService(); $cash = $srvCash->add($cashReg->id); $cash->openDate = stdtimefstr("2000-02-02 02:02:02"); $srvCash->update($cash); $this->cash = $cash; // User $srvUsers = new UsersService(); $user = new User("User", null, null, "0", true, false); $user->id = $srvUsers->create($user); $this->user = $user; // Currency $curr = new Currency("Eur", "€", ",", ".", "#,##0.00\$", 1, true, false); $srvCurr = new CurrenciesService(); $curr->id = $srvCurr->create($curr); $this->currency = $curr; }