Exemplo n.º 1
0
 public function setUp()
 {
     parent::setUp();
     $this->initModels([new User(), new Group(), new Membership(), new Customer()]);
     $group = new Group();
     $group->name = 'Administrators';
     $group->save();
     $group_prog = new Group();
     $group_prog->name = 'Programmers';
     $group_prog->save();
     $anton = new User();
     $anton->username = '******';
     $anton->password = '******';
     $anton->save();
     $group_prog->users->link($anton);
     $anton_home = new Customer();
     $anton_home->address = "Anton home";
     $anton_home->user = $anton;
     $anton_home->save();
     $anton_work = new Customer();
     $anton_work->address = "Anton work";
     $anton_work->user = $anton;
     $anton_work->save();
     $max = new User();
     $max->username = '******';
     $max->password = '******';
     $max->save();
     $group->users->link($max);
     $max_home = new Customer();
     $max_home->address = "Max home";
     $max_home->user = $max;
     $max_home->save();
 }
Exemplo n.º 2
0
 public function setUp()
 {
     parent::setUp();
     $this->basePath = realpath(__DIR__ . '/../../protected');
     $group = new Group();
     $group->name = 'Administrators';
     $group->save();
     $group_prog = new Group();
     $group_prog->name = 'Programmers';
     $group_prog->save();
     $anton = new User();
     $anton->username = '******';
     $anton->password = '******';
     $anton->save();
     $group_prog->users->link($anton);
     $anton_home = new Customer();
     $anton_home->address = "Anton home";
     $anton_home->user = $anton;
     $anton_home->save();
     $anton_work = new Customer();
     $anton_work->address = "Anton work";
     $anton_work->user = $anton;
     $anton_work->save();
     $max = new User();
     $max->username = '******';
     $max->password = '******';
     $max->save();
     $group->users->link($max);
     $group_prog->users->link($max);
     $max_home = new Customer();
     $max_home->address = "Max home";
     $max_home->user = $max;
     $max_home->save();
 }
Exemplo n.º 3
0
 public function setUp()
 {
     parent::setUp();
     $category = new Category();
     $category->name = 'test';
     $category->save();
     $user = new User();
     $user->password = 123456;
     $user->username = '******';
     $user->save();
     $customer = new Customer();
     $customer->user = $user;
     $customer->address = 'example super address';
     $customer->save();
     $products = [];
     foreach ([1, 2, 3, 4, 5] as $i) {
         $product = new Product();
         $product->name = $i;
         $product->price = $i;
         $product->description = $i;
         $product->category = $category;
         $product->save();
         $products[] = $product;
     }
     $order1 = new Order();
     $order1->customer = $customer;
     $order1->save();
     foreach ($products as $p) {
         $order1->products->link($p);
     }
     $order2 = new Order();
     $order2->customer = $customer;
     $order2->discount = 1;
     $order2->save();
     $order2->products = $products;
     $order2->save();
 }
Exemplo n.º 4
0
 public function setUp()
 {
     parent::setUp();
     $category = new Category();
     $category->name = 'test';
     $category->save();
     $product_list = new ProductList();
     $product_list->name = 'First product list';
     $product_list->date_action = '2014-04-29 10:35:45';
     $product_list->save();
     $user = new User();
     $user->password = 123456;
     $user->username = '******';
     $user->save();
     $customer = new Customer();
     $customer->user = $user;
     $customer->address = 'example super address';
     $customer->save();
     $products = [];
     foreach ([1, 2, 3, 4, 5] as $i) {
         $product = new Product();
         $product->name = $i;
         $product->price = $i;
         $product->description = $i;
         $product->category = $category;
         $product->save();
         $products[] = $product;
     }
     $order = new Order();
     $order->customer = $customer;
     $order->save();
     $order->products = $products;
     $order->save();
     $model = new Category();
     $this->prefix = $model->getDb()->tablePrefix;
 }
 public function setUp()
 {
     parent::setUp();
     $group = new Group();
     $group->name = 'Administrators';
     $group->save();
     $group_prog = new Group();
     $group_prog->name = 'Programmers';
     $group_prog->save();
     $anton = new User();
     $anton->username = '******';
     $anton->password = '******';
     $anton->save();
     $group->users->link($anton);
     $group_prog->users->link($anton);
     $anton_home = new Customer();
     $anton_home->address = "Anton home";
     $anton_home->user = $anton;
     $anton_home->save();
     $anton_work = new Customer();
     $anton_work->address = "Anton work";
     $anton_work->user = $anton;
     $anton_work->save();
     $max = new User();
     $max->username = '******';
     $max->password = '******';
     $max->save();
     $group->users->link($max);
     $group_prog->users->link($max);
     $max_home = new Customer();
     $max_home->address = "Max home";
     $max_home->user = $max;
     $max_home->save();
     $model = new Customer();
     $this->prefix = $model->getDb()->tablePrefix;
 }
Exemplo n.º 6
0
 public function testValuesList()
 {
     $group = new Group();
     $group->name = 'Administrators';
     $group->save();
     $groupProg = new Group();
     $groupProg->name = 'Programmers';
     $groupProg->save();
     $anton = new User();
     $anton->username = '******';
     $anton->password = '******';
     $anton->save();
     $groupProg->users->link($anton);
     $anton_home = new Customer();
     $anton_home->address = "Anton home";
     $anton_home->user = $anton;
     $anton_home->save();
     $anton_work = new Customer();
     $anton_work->address = "Anton work";
     $anton_work->user = $anton;
     $anton_work->save();
     $max = new User();
     $max->username = '******';
     $max->password = '******';
     $max->save();
     $group->users->link($max);
     $max_home = new Customer();
     $max_home->address = "Max home";
     $max_home->user = $max;
     $max_home->save();
     $values = Customer::objects()->valuesList(['address', 'user__username']);
     $this->assertEquals([['address' => 'Anton home', 'user__username' => 'Anton'], ['address' => "Anton work", 'user__username' => 'Anton'], ['address' => "Max home", 'user__username' => 'Max']], $values);
     $this->assertEquals([['address' => 'Anton home', 'user__username' => 'Anton'], ['address' => "Anton work", 'user__username' => 'Anton'], ['address' => "Max home", 'user__username' => 'Max']], Customer::objects()->valuesList(['address', 'user__username']));
     $this->assertEquals(['Anton', 'Anton', 'Max'], Customer::objects()->valuesList(['user__username'], true));
 }