Esempio n. 1
0
                 $price = $order->priceData('customer');
                 $view_name = 'order.price';
                 include smart_view('append.div');
                 exit;
                 break;
             default:
                 throw new Exception("unkown action: {$action}");
                 break;
         }
     }
     $customer = $customer->id;
     // for next
     break;
 case 'Admin':
 case 'SuperAdmin':
     $factories = Factory::names();
     // get some divs
     if ($by_ajax && is_numeric($target) && preg_match('/get_.+_div/', $action)) {
         include FrameFile::controller('order.get_div');
         exit;
     }
     // 对订单的操作,通过表单post过来的
     if ($action && $by_post && is_numeric($target)) {
         include FrameFile::controller('order.control');
         exit;
     }
     list($customer, $username, $factory) = _get('customer', 'username', 'factory');
     $conds = array_merge($conds, compact('username', 'factory'));
     $page['styles'][] = 'admin';
     break;
 default:
Esempio n. 2
0
File: test.php Progetto: name3/cheng
$superadmin = $user->instance();
$admin = $superadmin->createAdmin(compact('username', 'password'));
$ideal_arr = array('name' => $username, 'password' => md5($password), 'type' => 'Admin');
$id = Pdb::lastInsertId();
$real_arr = Pdb::fetchRow('name, password, type', User::$table, array('id=?' => $id));
test($real_arr, $ideal_arr, array('name' => 'Super Admin create Admin, db'));
// case 6 Admin update gold Price
begin_test();
$admin->updatePrice('PT950', '1903.21');
$admin->updatePrice('Au750', '1723.45');
test(1, 1, array('name' => 'Admin update gold Price'));
// case 7 Admin add Factory
begin_test();
$info = array('name' => '嘉黛_test', 'contact' => '吴小牛', 'phone' => '13526523659', 'qq' => '5833652584', 'city' => '湖北武汉');
$factory = $admin->addFactory($info);
test(count(Factory::names()), 1, array('name' => 'Admin add Factory'));
// case 8 Admin post Product, db
begin_test();
$prd_types = Product::types();
$info = array('name' => '唯爱心形群镶女戒_test', 'type' => reset(array_keys($prd_types)), 'material' => json_encode(array('PT950', '白18K金', '黄18K金', '红18K金')), 'rabbet_start' => '0.30', 'rabbet_end' => '0.60', 'small_stone' => 3, 'st_weight' => 2.1, 'image1_400' => '/test/static/img/i400-1.jpg', 'image2_400' => '/test/static/img/i400-2.jpg', 'image3_400' => '/test/static/img/i400-3.jpg', 'image1_thumb' => '/test/static/img/i80-1.jpg', 'image2_thumb' => '/test/static/img/i80-2.jpg', 'image3_thumb' => '/test/static/img/i80-3.jpg');
$product = $admin->postProduct($info);
// add more
// for ($i=0; $i < 50; $i++) {
//     $info2 = $info;
//     $info2['name'] = $info['name'] . $i;
//     $admin->postProduct($info2);
// }
// but what if we count?
test(Pdb::fetchRow('*', Product::$table, array('id=?' => $product->id)), $info, array('name' => 'Admin post Product, db', 'compare' => 'in'));
// case 9 Admin del Product
begin_test();