Ejemplo n.º 1
0
 function testDelete()
 {
     $name = "Zelds";
     $test_store = new Store($name);
     $test_store->save();
     $name = "Granite";
     $test_brand = new Brand($name);
     $test_brand->save();
     $test_brand->addStore($test_brand);
     $test_brand->delete();
     $this->assertEquals([], $test_brand->getStores());
 }
Ejemplo n.º 2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Store();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Store'])) {
         $model->attributes = $_POST['Store'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->store_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 3
0
 public function actionCreate()
 {
     $model = new Store();
     if ($_POST['Store']) {
         $accessKey = Yii::app()->params['qiniu']['accessKey'];
         $secretKey = Yii::app()->params['qiniu']['secretKey'];
         $auth = new Auth($accessKey, $secretKey);
         $bucket = 'urtime1';
         $token = $auth->uploadToken($bucket);
         $uploadMgr = new UploadManager();
         //上传logo
         if ($_FILES['image']['name'] != null) {
             $images = array($_FILES['image']);
             $images = $this->setImageInformation($images, $token, $uploadMgr);
             if ($images) {
                 $_POST['Store']['image'] = $images[0];
             }
             unset($_FILES['image']);
         }
         //上传营业执照
         if ($_FILES['bussiness_license1']['name'] != null || $_FILES['bussiness_license2']['name'] != null) {
             $images = array($_FILES['bussiness_license1'], $_FILES['bussiness_license2']);
             $images = $this->setImageInformation($images, $token, $uploadMgr);
             if ($images) {
                 // $images_str = implode(',',$images);
                 $_POST['Store']['bussiness_license'] = json_encode($images);
                 //$images_str;
             }
             unset($_FILES['bussiness_license1']);
             unset($_FILES['bussiness_license2']);
         }
         //上传介绍图片
         if ($_FILES['upImage']['name'] != null) {
             $images = $this->setImageInformation($_FILES, $token, $uploadMgr);
             if ($images) {
                 //$images_str = implode(',',$images);
                 $_POST['Store']['images_str'] = json_encode($images);
                 //$images_str;
             }
         }
         $model->attributes = $_POST['Store'];
         if ($model->validate() && $model->save()) {
             //$this->redirect('site/index');
             Yii::app()->user->setFlash('create', '成功', '失败');
             // Yii::app()->end();
             $this->redirect(array('/store/view'));
         }
     }
     $managers = Managers::model()->loadStaffAllModel();
     $this->render('create', ['model' => $model, 'managers' => $managers]);
 }
Ejemplo n.º 4
0
 public function actionCreate()
 {
     $model = new Store();
     if (isset($_POST['Store'])) {
         $model->setAttributes($_POST['Store']);
         if ($model->save()) {
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->end();
             } else {
                 $this->redirect(array('view', 'id' => $model->store_id));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 5
0
 public function store()
 {
     $rules = ['name' => 'required', 'address' => 'required', 'postal_code' => 'required', 'email' => 'required|email', 'phone' => 'required'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $password = Input::get('password');
         if (Input::has('store_id')) {
             $id = Input::get('store_id');
             $store = StoreModel::find($id);
             if ($password !== '') {
                 $store->secure_key = md5($store->salt . $password);
             }
         } else {
             $store = new StoreModel();
             if ($password === '') {
                 $alert['msg'] = 'You have to enter password';
                 $alert['type'] = 'danger';
                 return Redirect::route('company.store.create')->with('alert', $alert);
             }
             $store->salt = str_random(8);
             $store->token = str_random(8);
             $store->secure_key = md5($store->salt . $password);
             $store->company_id = Session::get('company_id');
         }
         $store->name = Input::get('name');
         $store->address = Input::get('address');
         $store->postal_code = Input::get('postal_code');
         $store->email = Input::get('email');
         $store->phone = Input::get('phone');
         $store->description = Input::get('description');
         $store->save();
         if (!Input::has('store_id')) {
             $status = new StatusModel();
             $status->store_id = $store->id;
             $startNo = rand(1, 100);
             $status->current_queue_no = $startNo;
             $status->last_queue_no = $startNo;
             $status->save();
         }
         $alert['msg'] = 'Store has been saved successfully';
         $alert['type'] = 'success';
         return Redirect::route('company.store')->with('alert', $alert);
     }
 }
Ejemplo n.º 6
0
 function testGetStores()
 {
     $store_name = "Beacons Closet";
     $new_store = new Store($store_name);
     $new_store->save();
     $store_name2 = "Buffalo Exchange";
     $new_store2 = new Store($store_name);
     $new_store2->save();
     $brand_name = "dr.martens";
     $new_brand = new Brand($brand_name);
     $new_brand->save();
     $new_brand->addStore($new_store);
     $new_brand->addStore($new_store2);
     var_dump($new_brand);
     $result = $new_brand->getStores();
     var_dump($result);
     $this->assertEquals([$new_store, $new_store2], $result);
 }
Ejemplo n.º 7
0
 public function actionCreateStore()
 {
     $model = new Store();
     if (isset($_POST['Store'])) {
         //		print_r($_POST);
         //		print_r($model->attributes);
         //		exit;
         $model->attributes = $_POST['Store'];
         $model->domain = 'shop' . time() . '.' . F::sg('site', 'shopDomain');
         $model->theme = 'default';
         if ($model->validate()) {
             if ($model->save()) {
                 $this->redirect('http://' . $model->domain);
             }
         } else {
             print_r($model->errors);
         }
     }
 }
Ejemplo n.º 8
0
 public function create()
 {
     $img = null;
     $tmp_img = Input::file('menu');
     $tmp_img ? $img = $tmp_img->move('imgs', str_random(12)) : false;
     $s = new Store();
     $s->name = Input::get('name');
     $s->tel = Input::get('tel');
     $s->menu = $img ? $img : null;
     $s->mime = $img ? $img->getMimeType() : null;
     $s->memo = Input::get('memo');
     $result = $s->save();
     if (!$result) {
         $img ? unlink($img) : false;
         $json = array('result' => false, 'error' => $s->errors()->all());
         return $json;
     }
     $s->result = true;
     return $s;
 }
Ejemplo n.º 9
0
 function test_addStore()
 {
     //Arrange
     $brand_name = "Nike";
     $test_brand = new Brand($brand_name);
     $test_brand->save();
     $store_name = "Flying Shoes";
     $test_store = new Store($store_name);
     $test_store->save();
     //Act
     $test_brand->addStore($test_store);
     //Assert
     $this->assertEquals($test_brand->getStores(), [$test_store]);
 }
Ejemplo n.º 10
0
 function test_getStores()
 {
     //Arrange
     $id = null;
     $store_name = "Fred Meyers";
     $test_store = new Store($id, $store_name);
     $test_store->save();
     $id2 = null;
     $store_name2 = "Safeway";
     $test_store2 = new Store($id2, $store_name2);
     $test_store2->save();
     $id3 = null;
     $brand_name = "Nike";
     $test_brand = new Brand($id3, $brand_name);
     $test_brand->save();
     $id4 = null;
     $brand_name2 = "Vans";
     $test_brand2 = new Brand($id4, $brand_name2);
     $test_brand2->save();
     //Act
     $test_brand->addStore($test_store);
     $test_brand->addStore($test_store2);
     $test_brand2->addStore($test_store2);
     //Assert
     $this->assertEquals($test_brand->getStores(), [$test_store, $test_store2]);
 }
Ejemplo n.º 11
0
 function testGetStores()
 {
     //Arrange
     $brand_name = "Super Kicks";
     $test_brand = new Brand($brand_name);
     $test_brand->save();
     $store_name = "Shoes Galore";
     $test_store = new Store($store_name);
     $test_store->save();
     $store_name2 = "Save Our Soles";
     $test_store2 = new Store($store_name2);
     $test_store2->save();
     //Act
     $test_brand->addStore($test_store);
     $test_brand->addStore($test_store2);
     $result = $test_brand->getStores();
     //Assert
     $this->assertEquals([$test_store, $test_store2], $result);
 }
Ejemplo n.º 12
0
 function testGetBrands()
 {
     //Arrange
     $name = "Shoe Store 1";
     $test_store = new Store($name);
     $test_store->save();
     $brand_name = "Brand name 1";
     $test_brand = new Brand($brand_name);
     $test_brand->save();
     $brand_name2 = "Brand name 2";
     $test_brand2 = new Brand($brand_name2);
     $test_brand2->save();
     //Act
     $test_store->addBrand($test_brand);
     $test_store->addBrand($test_brand2);
     $result = $test_store->getBrands();
     //Assert
     $this->assertEquals([$test_brand, $test_brand2], $result);
 }
Ejemplo n.º 13
0
 function test_find()
 {
     $test_name = "Nordstrom";
     $test_id = 1;
     $test_store = new Store($test_name, $test_id);
     $test_store->save();
     $test_name2 = "Bloomingdales";
     $test_id2 = 2;
     $test_store2 = new Store($test_name2, $test_id2);
     $test_store2->save();
     $result = Store::find($test_store->getId());
     $this->assertEquals($test_store, $result);
 }
Ejemplo n.º 14
0
 function test_getBrands()
 {
     //Arrange
     $name = "House of Shoes and Waffles";
     $address = "123 Street";
     $phone = "4-44";
     $test_store = new Store($name, $address, $phone);
     $test_store->save();
     $test_brand = new Brand("Nike");
     $test_brand->save();
     $test_brand2 = new Brand("Adidas");
     $test_brand2->save();
     //Act
     $test_store->addBrand($test_brand);
     $test_store->addBrand($test_brand2);
     //Assert
     $result = $test_store->getBrands();
     $this->assertEquals([$test_brand, $test_brand2], $result);
 }
Ejemplo n.º 15
0
 public function actionImportUnsubcribes()
 {
     $this->pageTitle = ' Import unsubscribes | ' . Yii::app()->name;
     $this->breadcrumbs = array('Import unsubscribes');
     ini_set('auto_detect_line_endings', true);
     if (isset($_POST['import'])) {
         if (!strlen($_POST['organisation_id'])) {
             Yii::app()->user->setFlash('error', 'Choose an organisation');
         } else {
             //print_r($_FILES);
             //exit();
             if (!strlen($_FILES['csv']['name'])) {
                 Yii::app()->user->setFlash('error', 'Choose a file');
             } else {
                 $dupeCount = 0;
                 $suppressionCount = 0;
                 $emailsChecked = array();
                 $emailDupeCount = 0;
                 $totalCount = 0;
                 $noRecordCount = 0;
                 if (($handle = fopen($_FILES['csv']['tmp_name'], "r")) !== FALSE) {
                     while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                         if (sizeof($data) > 1) {
                             Yii::app()->user->setFlash('error', 'File should only contain 1 column');
                             break;
                         } else {
                             $totalCount++;
                             $Store = new Store();
                             $email = strtolower(trim(mb_convert_encoding($data[0], 'UTF-8')));
                             if (in_array($email, $emailsChecked)) {
                                 $emailDupeCount++;
                                 continue;
                             }
                             //add email to emails checked
                             $emailsChecked[] = $email;
                             //print $Store->encryptEmail(trim(mb_convert_encoding($data[0], 'UTF-8')));exit();
                             // Check for matching email in store table
                             $StoreRows = Store::model()->with('store2contact')->findAll(array('condition' => 'origin_organisation_id = :org_id AND email = :email', 'params' => array(':email' => $Store->encryptEmail($email), ':org_id' => (int) $_POST['organisation_id'])));
                             if (sizeof($StoreRows)) {
                                 foreach ($StoreRows as $Store) {
                                     if (is_null($Store->store2contact)) {
                                         continue;
                                     }
                                     // Check for existing based on store2contact id
                                     $Suppression = SuppressionList::model()->find(array('condition' => 'store2contact_id = :store2contact_id', 'params' => array(':store2contact_id' => $Store->store2contact->id)));
                                     if (is_null($Suppression)) {
                                         $Suppression = new SuppressionList();
                                         $Suppression->type = SuppressionList::TYPE_UNSUBSCRIBE;
                                         // always save the store id against this row
                                         $Suppression->store_id = $Store->id;
                                         $Suppression->store2contact_id = $Store->store2contact->id;
                                         //We DO NOT need the warehouse id, we're not supressing from everything.
                                         //$Suppression->warehouse_id = $Store->store2contact->contact_warehouse_id;
                                         $Suppression->date = date('Y-m-d H:i:s');
                                         if ($Suppression->save()) {
                                             $suppressionCount++;
                                         }
                                         $Store->contact_email = 0;
                                         $Store->save(true, array("contact_email"));
                                     } else {
                                         $dupeCount++;
                                     }
                                 }
                             } else {
                                 $noRecordCount++;
                             }
                         }
                     }
                     Yii::app()->user->setFlash('success', $suppressionCount . ' suppression rows saved. ' . $dupeCount . ' were already suppressed. Number of duplicate emails was ' . $emailDupeCount . '. Total number of rows processed was ' . $totalCount . '. We could not find a match for ' . $noRecordCount . '.');
                     $this->refresh();
                 }
                 fclose($handle);
             }
         }
     }
     $this->render('importUnsubcribes', array());
 }
Ejemplo n.º 16
0
 function testGetBrands()
 {
     $name = "ShoeStore";
     $id = 1;
     $test_store = new Store($name, $id);
     $test_store->save();
     $name = "Asics";
     $id3 = 3;
     $test_brand = new Brand($name, $id3);
     $test_brand->save();
     $name2 = "Nike";
     $id2 = 2;
     $test_brand2 = new Brand($name2, $id2);
     $test_brand2->save();
     //Act
     $test_store->addBrand($test_brand);
     $test_store->addBrand($test_brand2);
     //Assert
     $this->assertEquals($test_store->getBrands(), [$test_brand, $test_brand2]);
 }
Ejemplo n.º 17
0
 function test_getBrands()
 {
     //Arrange
     $retailer = "Nordstrom";
     $address = "1234 SW Main Street";
     $phone = "123-456-7890";
     $id = null;
     $test_store = new Store($retailer, $address, $phone, $id);
     $test_store->save();
     $name = "Nike";
     $stock = 5;
     $test_brand = new Brand($name, $stock, $id);
     $test_brand->save();
     $name2 = "Adidas";
     $stock2 = 8;
     $test_brand2 = new Brand($name2, $stock2, $id);
     $test_brand2->save();
     //Act
     $test_store->addBrand($test_brand);
     $test_store->addBrand($test_brand2);
     $result = $test_store->getBrands();
     //Assert
     $this->assertEquals([$test_brand, $test_brand2], $result);
 }
Ejemplo n.º 18
0
 function testGetStores()
 {
     //Arrange
     $brand_name = "Sketchers";
     $id = null;
     $test_brand = new Brand($brand_name, $id);
     $test_brand->save();
     $another_brand = "Doc Martin";
     $test_brand2 = new Brand($another_brand, $id);
     $test_brand2->save();
     $store_name = "Norstrom";
     $test_store = new Store($store_name, $id);
     $test_store->save();
     //Act
     $test_store->addBrand($test_brand);
     $test_store->addBrand($test_brand2);
     $result = $test_store->getBrands();
     //Assert
     $this->assertEquals([$test_brand, $test_brand2], $result);
 }
Ejemplo n.º 19
0
$server = 'mysql:host=localhost;dbname=shoes';
$username = '******';
$password = '******';
$DB = new PDO($server, $username, $password);
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
use Symfony\Component\HttpFoundation\Request;
Request::enableHttpMethodParameterOverride();
//Routes
$app->get('/', function () use($app) {
    return $app['twig']->render('index.html.twig', array('stores' => Store::getAll(), 'brands' => Brand::getAll()));
});
$app->post('/add_store', function () use($app) {
    $id = null;
    $store_name = $_POST['store_name'];
    $new_store = new Store($store_name, $id);
    $new_store->save();
    return $app['twig']->render('index.html.twig', array('stores' => Store::getAll(), 'brands' => Brand::getAll()));
});
$app->post('/delete_stores', function () use($app) {
    Store::deleteAll();
    return $app['twig']->render('index.html.twig', array('stores' => Store::getAll(), 'brands' => Brand::getAll()));
});
$app->post('/add_brand', function () use($app) {
    $id = null;
    $name = $_POST['brand_name'];
    $new_brand = new Brand($name, $id);
    $new_brand->save();
    return $app['twig']->render('index.html.twig', array('stores' => Store::getAll(), 'brands' => Brand::getAll()));
});
$app->post('/delete_brands', function () use($app) {
    Brand::deleteAll();
Ejemplo n.º 20
0
 function test_delete()
 {
     //Arrange
     $id = null;
     $store_name = "New Seasons";
     $test_store = new Store($id, $store_name);
     $test_store->save();
     $id2 = null;
     $store_name2 = "Whole Foods";
     $test_store2 = new Store($id2, $store_name2);
     $test_store2->save();
     //Act
     $test_store->delete();
     $result = Store::getAll();
     //Assert
     $this->assertEquals($test_store2, $result[0]);
 }
Ejemplo n.º 21
0
 function testgetBrands()
 {
     //Arrange
     $name1 = "shoe store";
     $location = "123 n fake dr";
     $id1 = 4;
     $test_store = new Store($name1, $location, $id1);
     $test_store->save();
     $name = "nike";
     $id = 1;
     $test_brand = new Brand($name, $id);
     $test_brand->save();
     $name2 = "addidas";
     $id2 = 2;
     $test_brand2 = new Brand($name2, $id2);
     $test_brand2->save();
     //Act
     $test_store->addBrand($test_brand);
     $test_store->addBrand($test_brand2);
     $result = $test_store->getBrands();
     //Assert
     $this->assertEquals([$test_brand, $test_brand2], $result);
 }
Ejemplo n.º 22
0
 function test_find()
 {
     //Arrange
     $store_name = "Portland Running Company";
     $id = null;
     $test_store = new Store($store_name, $id);
     $test_store->save();
     $store_name2 = "New Balance";
     $test_store2 = new Store($store_name2, $id);
     $test_store2->save();
     //Act
     $id = $test_store->getId();
     $result = Store::find($id);
     //Assert
     $this->assertEquals($test_store, $result);
 }
Ejemplo n.º 23
0
 function testGetStores()
 {
     //Arrange
     $store_name = "Happy Lemon";
     $test_store = new Store($store_name, $id = null);
     $test_store->save();
     $store_name2 = "Chatime";
     $test_store2 = new Store($store_name2, $id = null);
     $test_store2->save();
     $brand_name = "Feiyue";
     $test_brand = new Brand($brand_name, $id = null);
     $test_brand->save();
     //Act
     $test_brand->addStore($test_store);
     $test_brand->addStore($test_store2);
     //Assert
     $this->assertEquals($test_brand->getStores(), [$test_store, $test_store2]);
 }
Ejemplo n.º 24
0
 function testAddStore()
 {
     //Assert
     $brand_name = "Nike";
     $test_brand = new Brand($brand_name);
     $test_brand->save();
     $store_location = "Lloyd Center";
     $test_store = new Store($store_location);
     $test_store->save();
     //Act
     $test_brand->addStore($test_store);
     $result = $test_brand->getStores();
     //Assert
     $this->assertEquals([$test_store], $result);
 }
 function testGetStores()
 {
     // Arrange
     $brand_name = "Babbling Brooks";
     $test_Brand = new Brand($brand_name);
     $test_Brand->save();
     $store_name = "Get Your Kicks Co.";
     $test_Store = new Store($store_name);
     $test_Store->save();
     $store_name2 = "I Wanna Run Fast Co.";
     $test_Store2 = new Store($store_name2);
     $test_Store2->save();
     // Act
     $test_Brand->addStore($test_Store);
     $test_Brand->addStore($test_Store2);
     $result = $test_Brand->getStores();
     // Assert
     $this->assertEquals([$test_Store, $test_Store2], $result);
 }
Ejemplo n.º 26
0
 function test_hasStore()
 {
     //Arrange
     //Make two test Brands
     $name = "Nike";
     $website = "http://www.nike.com";
     $test_brand = new Brand($name, $website);
     $test_brand->save();
     $name2 = "Adidas";
     $website2 = "http://www.adidas.com";
     $test_brand2 = new Brand($name2, $website2);
     $test_brand2->save();
     //Make two test Stores
     $name = "Burchs";
     $location = "Oakway Center";
     $phone = "5415131122";
     $test_store = new Store($name, $location, $phone);
     $test_store->save();
     $name2 = "Payless ShoeSource";
     $location2 = "Valley River Center";
     $phone2 = "5415130809";
     $test_store2 = new Store($name2, $location2, $phone2);
     $test_store2->save();
     // Add both stores to second Brand
     $test_brand2->addStore($test_store);
     $test_brand2->addStore($test_store2);
     //Act
     $true_result = $test_brand2->hasStore($test_store2->getId());
     $false_result = $test_brand->hasStore($test_store2->getId());
     //Assert
     $this->assertEquals(true, $true_result);
     $this->assertEquals(false, $false_result);
 }
Ejemplo n.º 27
0
    define('DIR_ROOT', dirname(__FILE__));
}
if (!defined('DIR_KVZLIB')) {
    $lookIn = array('/Users/kevin/workspace/kvzlib', '/home/kevin/workspace/kvzlib', DIR_ROOT . '/ext/kvzlib');
    foreach ($lookIn as $dir) {
        if (is_dir($dir) && file_exists($dir . '/kvzlib.php')) {
            define('DIR_KVZLIB', $dir);
            break;
        }
    }
    if (!defined('DIR_KVZLIB')) {
        trigger_error('KvzLib not found in either: ' . implode(', ', $lookIn), E_USER_ERROR);
    }
}
define('IMDBPHP_CONFIG', DIR_ROOT . '/config/imdb.php');
ini_set("include_path", DIR_KVZLIB . ":" . DIR_ROOT . ":" . ini_get("include_path"));
require_once DIR_KVZLIB . '/php/classes/KvzShell.php';
require_once DIR_KVZLIB . '/php/classes/KvzHTML.php';
require_once DIR_KVZLIB . '/php/all_functions.php';
require_once DIR_ROOT . '/libs/crawler.php';
require_once DIR_ROOT . '/libs/movie.php';
require_once DIR_ROOT . '/libs/store.php';
require_once 'imdb.class.php';
$outDir = '/home/kevin/Dropbox/Public/cinema';
$outFile = 'kijken.html';
$crawlerOptions = array('dir' => '/data/moviesHD', 'minSize' => '600M', 'cachedir' => DIR_ROOT . '/cache', 'photodir' => $outDir . '/images');
$Crawler = new Crawler($crawlerOptions);
$movies = $Crawler->crawl();
$Store = new Store($movies, 'html', array('photovirt' => 'images', 'outputdir' => $outDir, 'outputfile' => $outFile, 'separate_on_dir' => 1));
$Store->save();
#$Store->output();
Ejemplo n.º 28
0
 function test_brand_getStore()
 {
     //Arrange
     $brand_name = "Nike";
     $id1 = 1;
     $test_brand = new Brand($brand_name, $id1);
     $test_brand->save();
     $store_name2 = "Goody New Shoes";
     $test_store2 = new Store($store_name2);
     $test_store2->save();
     $test_brand->addStore($test_store2);
     $store_name = "Groos Shoes";
     $test_store = new Store($store_name);
     $test_store->save();
     $test_brand->addStore($test_store);
     //Act
     $result = $test_brand->getStores();
     //Assert
     $this->assertEquals([$test_store2, $test_store], $result);
 }
Ejemplo n.º 29
0
Request::enableHttpMethodParameterOverride();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
//GETS
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig');
});
$app->get("/stores", function () use($app) {
    return $app['twig']->render('stores.html.twig', array('stores' => Store::getAll()));
});
$app->get("/brands", function () use($app) {
    return $app['twig']->render('brands.html.twig', array('brands' => Brand::getAll()));
});
//POSTS
$app->post("/stores", function () use($app) {
    $store = new Store($_POST['store_name']);
    $store->save();
    return $app['twig']->render('stores.html.twig', array('stores' => Store::getAll()));
});
$app->post("/brands", function () use($app) {
    $brand = new Brand($_POST['brand_name']);
    $brand->save();
    return $app['twig']->render('brands.html.twig', array('brands' => Brand::getAll()));
});
//EDIT GETS
$app->get("/stores/{id}", function ($id) use($app) {
    $store = Store::find($id);
    return $app['twig']->render('store.html.twig', array('store' => $store, 'brands' => $store->getBrands(), 'all_brands' => Brand::getAll()));
});
$app->get("/brands/{id}", function ($id) use($app) {
    $brand = Brand::find($id);
    return $app['twig']->render('brand.html.twig', array('brand' => $brand, 'stores' => $brand->getStores(), 'all_stores' => Store::getAll()));
Ejemplo n.º 30
0
 function testGetStores()
 {
     //Arrange
     $beer_name = "Your mom";
     $style = "IPA";
     $abv = 4;
     $ibu = 6;
     $container = "bottle";
     $brewery = "daddy";
     $id = 1;
     $image = "../img/test.jpg";
     $test_beer = new Beer($beer_name, $style, $abv, $ibu, $container, $brewery, $image, $id);
     $test_beer->save();
     $store_name = "M&M";
     $category = "Black Market";
     $region = "unknown";
     $address = "SW";
     $id2 = 2;
     $test_store = new Store($store_name, $category, $region, $address);
     $test_store->save();
     $store_name2 = "M&M2";
     $category2 = "Black Market2";
     $region2 = "unknown2";
     $address2 = "SW2";
     $id3 = 3;
     $test_store2 = new Store($store_name2, $category2, $region2, $address2);
     $test_store2->save();
     //Act
     $test_beer->addStore($test_store->getId());
     $test_beer->addStore($test_store2->getId());
     $result = $test_beer->getStores();
     //Assert
     $this->assertEquals([$test_store, $test_store2], $result);
 }