Exemple #1
0
 public function testFactory()
 {
     $this->assertInstanceOf('Store_Local', Store::factory());
     $this->assertInstanceOf('Store_Local', Store::factory(Store::Local));
     $this->assertInstanceOf('Store_Session', Store::factory(Store::Session));
     $this->assertEquals(false, Store::factory('Undefined type'));
 }
 /**
  * @covers QueueController::Add
  * @todo Implement testAdd().
  */
 public function testAdd()
 {
     $person = Person::factory('adult');
     $person->name = 'Poehavshiy';
     $person->add();
     $store = Store::factory('Grocery');
     $store->name = 'Prison';
     $store->add();
     $product = new Product();
     $product->name = 'Sladkiy hleb';
     $product->add();
     $request = Application::getInstance()->request;
     $request->setParams(array('storeId' => $store->id, 'personId' => $person->id, 'product_' . $product->id => 'on'));
     $personId = $request->p('personId');
     $storeId = $request->p('storeId');
     $store = Store::get($storeId);
     $person = Person::get($personId);
     $store->queue->add($person);
     $person->basket->drop();
     $name = 'product_' . $product->id;
     $value = $product;
     if (preg_match_all('/^product_(\\d+)$/', $name, $matches)) {
         $person->basket->add(Product::get($matches[1][0]));
     }
 }
Exemple #3
0
 public function testSetData()
 {
     $store = Store::factory(Store::Local, 'test');
     $store->set('key', 'val');
     $data = array('key2' => 'val2', 'key3' => 'val3');
     $store->setData($data);
     $this->assertEquals($data, $store->getData());
 }
 public function Add()
 {
     $this->_response()->asJSON();
     try {
         $name = $this->_request()->p('name');
         $type = $this->_request()->p('type');
         $store = Store::factory($type);
         $store->name = trim($name);
         $store->add();
         return array('id' => $store->id, 'name' => $store->name, 'type' => $store->type, 'expl' => $store::explainType());
     } catch (Exception $e) {
         return array('error' => $e->getMessage());
     }
 }
Exemple #5
0
 public function __construct()
 {
     $this->_session = Store::factory(Store::Session, 'install');
     $this->_docRoot = DVELUM_ROOT . '/';
     $this->_wwwRoot = '/';
     $docRoot = $_SERVER['DOCUMENT_ROOT'];
     if ($docRoot[strlen($docRoot) - 1] === '/') {
         $docRoot = substr($docRoot, 0, -1);
     }
     $uri = $_SERVER['REQUEST_URI'];
     $parts = explode('/', $uri);
     for ($i = 1; $i < sizeof($parts); $i++) {
         if ($parts[$i] === 'install') {
             break;
         }
         $this->_wwwRoot .= $parts[$i] . '/';
     }
 }
 /**
  * @covers Assortment::add
  * @todo Implement testAdd().
  */
 public function testAdd()
 {
     $db = Application::getInstance()->mysqli;
     $db->query('DELETE FROM Product');
     $db->query('DELETE FROM Store');
     $db->query('DELETE FROM Assortment');
     for ($i = 1; $i < 3; $i++) {
         $store = Store::factory('grocery');
         $store->name = 'store_' . $i;
         $store->add();
         $stores[] = $store;
     }
     for ($i = 1; $i < 10; $i++) {
         $product = new Product();
         $product->name = 'product_' . $i;
         $product->add();
         $products[] = $product;
         $map[$product->id] = rand(0, 2);
     }
     $a = $stores[1]->assortment;
     $a->map($map);
 }
Exemple #7
0
 /**
  * Instantiate storage
  * @return Store
  */
 protected static function _connectStore()
 {
     self::$_store = Store::factory(Store::Local, 'class_' . __CLASS__);
     return self::$_store;
 }
Exemple #8
0
 /**
  * Get link to local data storage (store runtime data)
  * @return Store_Local
  * @deprecated
  */
 public static function getStorage()
 {
     return Store::factory(Store::Local);
 }
Exemple #9
0
 public function __construct()
 {
     if (!self::$_storage) {
         self::$_storage = Store::factory(Store::Session, 'security_csrf');
     }
 }
Exemple #10
0
 /**
  *  Remove User authorization data (the session remains active, while the User is logged out)
  */
 public function logout()
 {
     $ses = Store::factory(Store::Session);
     $ses->set('auth', false);
     $ses->set('auth_id', false);
     $this->_authChecked = false;
     $this->_info = array();
     $this->_permissions = null;
 }