Beispiel #1
0
 static function find($searchId)
 {
     $stores_returned = Store::getAll();
     foreach ($stores_returned as $store) {
         if ($searchId == $store->getId()) {
             return $store;
         }
     }
 }
 static function find($id)
 {
     $db_stores = Store::getAll();
     foreach ($db_stores as $store) {
         if ($id == $store->getId()) {
             return $store;
         }
     }
     return null;
 }
Beispiel #3
0
 function testGetAll()
 {
     $name = "LuLus";
     $test_store = new Store($name);
     $test_store->save();
     $name2 = "Barts";
     $test_store2 = new Store($name);
     $test_store2->save();
     $result = Store::getAll();
     $this->assertEquals([$test_store, $test_store2], $result);
 }
Beispiel #4
0
 static function find($search_id)
 {
     $found_store = null;
     $all_stores = Store::getAll();
     foreach ($all_stores as $store) {
         if ($store->getId() == $search_id) {
             $found_store = $store;
         }
     }
     return $found_store;
 }
Beispiel #5
0
 static function find($search_id)
 {
     $found_brand = null;
     $brands = Store::getAll();
     foreach ($brands as $brand) {
         $brand_id = $brand->getId();
         if ($brand_id == $search_id) {
             $found_brand = $brand;
         }
     }
     return $found_brand;
 }
Beispiel #6
0
 static function findByName($search_name)
 {
     $found_store = null;
     $stores = Store::getAll();
     foreach ($stores as $store) {
         $store_name = $store->getName();
         if ($store_name == $search_name) {
             $found_store = $store;
         }
     }
     return $found_store;
 }
Beispiel #7
0
 function test_deleteAll()
 {
     //Arrange
     $store_name = "Flying Shoes";
     $test_store = new Store($store_name);
     $test_store->save();
     //Act
     Store::deleteAll();
     $result = Store::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
Beispiel #8
0
 static function find($search_id)
 {
     $found_store = NULL;
     $stores = Store::getAll();
     foreach ($stores as $store) {
         $store_id = $store->getId();
         if ($store_id == $search_id) {
             $found_store = $store;
         }
     }
     return $found_store;
 }
Beispiel #9
0
 static function find($search_id)
 {
     $found = null;
     $stores = Store::getAll();
     foreach ($stores as $store) {
         $store_id = $store->getId();
         if ($store_id == $search_id) {
             $found = $store;
         }
         //end of if
     }
     //end foreach
     return $found;
 }
Beispiel #10
0
 function test_delete()
 {
     $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();
     $test_store->delete();
     $result = Store::getAll();
     $this->assertEquals([$test_store2], $result);
 }
Beispiel #11
0
 function testDeleteStore()
 {
     //Arrange
     $store_name = "Norstrom";
     $id = null;
     $test_store = new Store($store_name, $id);
     $test_store->save();
     $another_store = "Madewell";
     $test_store2 = new Store($another_store, $id);
     $test_store2->save();
     //Act
     $test_store->delete();
     $result = Store::getAll();
     //Assert
     $this->assertEquals([$test_store2], $result);
 }
Beispiel #12
0
 function testDeleteAll()
 {
     //Arrange
     $name = "Clogs-N-More";
     $id = 1;
     $test_store = new Store($name, $id);
     $test_store->save();
     $name2 = "Shoe Depot";
     $id2 = 1;
     $test_store2 = new Store($name2, $id2);
     $test_store2->save();
     //Act
     Store::deleteAll();
     $result = Store::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
Beispiel #13
0
 function test_delete()
 {
     //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();
     $retailer2 = "Macys";
     $address2 = "400 SW 6th Avenue";
     $phone2 = "888-888-8888";
     $test_store2 = new Store($retailer2, $address2, $phone2, $id);
     $test_store2->save();
     //Act
     $test_store->delete();
     $result = Store::getAll();
     //Assert
     $this->assertEquals($test_store2, $result[0]);
 }
Beispiel #14
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]);
 }
Beispiel #15
0
 function testDeleteAll()
 {
     //Arrange
     $name = "shoe store";
     $location = "1234 nw 1st street";
     $id = 4;
     $test_store = new Store($name, $location, $id);
     $test_store->save();
     $name2 = "other store";
     $location2 = "5555 sw 2nd street";
     $id2 = 3;
     $test_store2 = new Store($name2, $location2, $id2);
     $test_store2->save();
     //Act
     Store::deleteAll();
     $result = Store::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
Beispiel #16
0
 function test_getAll()
 {
     //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
     $result = Store::getAll();
     //Assert
     $this->assertEquals([$test_store, $test_store2], $result);
 }
Beispiel #17
0
 function test_delete()
 {
     //Arrange
     $name = "House of Shoes and Waffles";
     $address = "123 Street";
     $phone = "4-44";
     $test_store = new Store($name, $address, $phone);
     $test_store->save();
     $name2 = "Bob's Shoe Palace";
     $address2 = "456 Main Street";
     $phone2 = "1-800-NEW-SHOE";
     $test_store2 = new Store($name, $address, $phone);
     $test_store2->save();
     //Act
     $test_store->delete();
     $result = Store::getAll();
     //Assert
     $this->assertEquals([$test_store2], $result);
 }
Beispiel #18
0
//EDIT A BRAND link
$app->get("/brand/{id}/edit", function ($id) use($app) {
    $brand = Brand::find($id);
    return $app['twig']->render("edit_brand.html.twig", array("brand" => $brand, "brands" => Brand::getAll(), "stores" => $brand->getStores(), 'stores' => Store::getAll()));
});
//DELETE ALL STORES/BRANDS
$app->post("/delete_all", function () use($app) {
    Store::deleteAll();
    Brand::deleteAll();
    return $app['twig']->render('index.html.twig', array('stores' => Store::getAll(), 'brands' => Brand::getAll()));
});
//DELETE INDIVIDUAL STORE
$app->delete("/store/{id}/delete", function ($id) use($app) {
    $store = Store::find($id);
    $store->deleteStore();
    return $app['twig']->render('index.html.twig', array('stores' => Store::getAll(), 'brands' => Brand::getAll()));
});
//UPDATE
$app->patch("/store/{id}", function ($id) use($app) {
    $store = Store::find($id);
    if (!empty($_POST['name'])) {
        $new_name = $_POST['name'];
        $store->updateName($new_name);
    }
    if (!empty($_POST['add_brand'])) {
        $brand_name = $_POST['add_brand'];
        $store->addBrand($store->checkBrand($brand_name));
    }
    return $app['twig']->render('index.html.twig', array('stores' => Store::getAll(), 'brands' => Brand::getAll()));
});
return $app;
Beispiel #19
0
$app->get('/store/{id}', function ($id) use($app) {
    $store = Store::find($id);
    return $app['twig']->render('store_edit.html.twig', array('store' => $store));
});
$app->patch('/stores/{id}', function ($id) use($app) {
    $store = Store::find($id);
    $store->update($_POST['name']);
    $brands = $store->getBrands();
    $all_brands = Brand::getAll();
    return $app['twig']->render('stores.html.twig', array('store' => $store, 'brands' => $brands, 'all_brands' => $all_brands));
});
$app->delete('/stores/{id}', function ($id) use($app) {
    $store = Store::find($id);
    $store->delete();
    return $app['twig']->render('index.html.twig', array('stores' => Store::getAll(), 'brands' => Brand::getAll()));
});
$app->get('/brands/{id}', function ($id) use($app) {
    $brand = Brand::find($id);
    $stores = $brand->getStores();
    $all_stores = Store::getAll();
    return $app['twig']->render('brands.html.twig', array('brand' => $brand, 'stores' => $stores, 'all_stores' => $all_stores));
});
$app->post('/add_stores', function () use($app) {
    $brand = Brand::find($_POST['brand_id']);
    $store = Store::find($_POST['store_id']);
    $brand->addStore($store);
    $stores = $brand->getStores();
    $all_stores = Store::getAll();
    return $app['twig']->render('brands.html.twig', array('brand' => $brand, 'stores' => $stores, 'all_stores' => $all_stores));
});
return $app;
Beispiel #20
0
 function testDeleteAll()
 {
     $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();
     Store::deleteAll();
     $result = Store::getAll();
     $this->assertEquals([], $result);
 }
Beispiel #21
0
    return $app['twig']->render('store.html.twig', array('store' => $store, 'brands' => $store->getBrands(), 'store_update' => false, 'form_check' => false));
});
$app->post("/delete_stores", function () use($app) {
    Store::deleteAll();
    return $app['twig']->render('index.html.twig', array('stores' => Store::getAll(), 'form_check' => false));
});
$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(), 'form_check' => false, 'store_update' => false));
});
// This route deletes specific store
$app->delete("/delete_store/{id}", function ($id) use($app) {
    $id = $_POST['store_id'];
    $store = Store::find($id);
    $store->delete();
    return $app['twig']->render('index.html.twig', array('stores' => Store::getAll(), 'form_check' => false));
});
$app->get("/form_brand", function () use($app) {
    $store = Store::find($_GET['store_id']);
    return $app['twig']->render('store.html.twig', array('store' => $store, 'brands' => $store->getBrands(), 'form_check' => true, 'store_update' => false));
});
$app->post("/add_brand", function () use($app) {
    $name = $_POST['name'];
    $brand = new Brand($name, $id = null);
    $brand->save();
    $store_id = $_POST['store_id'];
    $store = Store::find($store_id);
    $store->addBrand($brand->getId());
    return $app['twig']->render('store.html.twig', array('store' => $store, 'brands' => $store->getBrands(), 'form_check' => false, 'store_update' => false));
});
// This route deletes a specific brand from a store
 function testDelete()
 {
     //Arrange
     $name = "Shoe Store 1";
     $test_store = new Store($name);
     $test_store->save();
     $name2 = "Shoe Store 2";
     $test_store2 = new Store($name2);
     $test_store2->save();
     //Act
     $test_store->delete();
     $result = Store::getAll();
     //Assert
     $this->assertEquals([$test_store2], $result);
 }
 function testDeleteStore()
 {
     //Arrange
     $id = null;
     $store_name = "Nordstrom";
     $test_store = new Store($store_name, $id);
     $test_store->save();
     $store_name2 = "Footlocker";
     $test_store2 = new Store($store_name2, $id);
     $test_store2->save();
     //Act
     $test_store->delete();
     //Assert
     $result = Store::getAll();
     $this->assertEquals([$test_store2], $result);
 }
Beispiel #24
0
    return $app['twig']->render('stores.html.twig', array('stores' => Store::getAll(), 'user' => $user[0]));
});
//
$app->get("/{user_id}/search_store", function ($user_id) use($app) {
    $search_store = Store::find($_GET['search_field'], $_GET['search_term']);
    $user = User::find("id", $user_id);
    return $app['twig']->render('store_search.html.twig', array('search_store' => $search_store, 'user' => $user[0]));
});
//from stores
//add and save new store
//show all stores
$app->post("/{user_id}/stores", function ($user_id) use($app) {
    $store = new Store($_POST['store_name'], $_POST['category'], $_POST['region'], $_POST['address']);
    $store->save();
    $user = User::find("id", $user_id);
    return $app['twig']->render('stores.html.twig', array('stores' => Store::getAll(), 'user' => $user[0]));
});
//from stores
//find store
//show store
$app->get("/{user_id}/store/{store_id}", function ($user_id, $store_id) use($app) {
    $user = User::find("id", $user_id);
    $store = Store::find("id", $store_id);
    return $app['twig']->render('store.html.twig', array('store' => $store[0], 'user' => $user[0], 'beers' => $store[0]->getBeers(), 'all_beers' => Beer::getAll()));
});
//from store
//add beer to store
//show store
$app->post("/{user_id}/store/{store_id}", function ($user_id, $store_id) use($app) {
    $store = Store::find("id", $store_id);
    $beer = Beer::find("id", $_POST['beer_id']);
Beispiel #25
0
 function test_deleteAll()
 {
     $store_name = "george shoe store ";
     $test_store = new Store($store_name);
     $test_store->save();
     $store_name2 = "kramer shoe store ";
     $test_store2 = new Store($store_name2);
     $test_store2->save();
     //Act
     Store::deleteAll();
     $result = Store::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
Beispiel #26
0
 function testDeleteAll()
 {
     //Arrange
     $store_name = "Chill N Fill";
     $id = 1;
     $category = "bar";
     $region = "North Portland";
     $address = "5215 N Lombard Portland, OR 97203";
     $test_store = new Store($store_name, $category, $region, $address, $id);
     $test_store->save();
     $store_name2 = "Growler Guys";
     $id2 = 1;
     $category2 = "bottle shop";
     $region2 = "NE Portland";
     $address2 = "5553 N Lombard Portland, OR 97444";
     $test_store2 = new Store($store_name2, $category2, $region2, $address2, $id2);
     $test_store2->save();
     //Act
     Store::deleteAll();
     $result = Store::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
Beispiel #27
0
$app->post("/add_brand", function () use($app) {
    $brand = new Brand($_POST['name']);
    $brand->save();
    return $app['twig']->render('brands.html.twig', array('brands' => Brand::getAll()));
});
//deletes all brands
$app->post("/delete_all_brands", function () use($app) {
    Brand::deleteAll();
    return $app['twig']->render('brands.html.twig', array('brands' => Brand::getAll()));
});
$app->get("/brands/{id}/view", function ($id) use($app) {
    $brand = Brand::find($id);
    $stores->getStores();
    return $app['twig']->render('brands_in_store.html.twig', array('brand' => $brand, 'stores' => $stores));
});
//takes user to an individual brand that lists all stores
$app->get("/brands/{id}", function ($id) use($app) {
    $brand = Brand::find($id);
    $store_selling_brands = $brand->getStores();
    return $app['twig']->render('brands_in_store.html.twig', array('brand' => $brand, 'store' => $store_selling_brands, 'all_stores' => Store::getAll()));
});
//adds store to a brand on individual brand page
$app->post("/brands/{id}", function ($id) use($app) {
    $brand = Brand::find($_POST['brand_id']);
    $store = Store::find($_POST['store_id']);
    $brand->addStore($store);
    $new_store = new Store($_POST['name'], $_POST['location'], $_POST['phone']);
    $new_store->save();
    return $app['twig']->render('brands_in_store.html.twig', array('brand' => $brand, 'stores' => $brand->getStores(), 'all_stores' => Store::getAll()));
});
return $app;
Beispiel #28
0
 function testDeleteStore()
 {
     //arrange
     $name = "Store1";
     $id = 1;
     $test_store = new Store($name, $id);
     $test_store->save();
     $name2 = "Store2";
     $id2 = 2;
     $test_store2 = new Store($name2, $id2);
     $test_store2->save();
     //act
     $test_store->deleteStore();
     //assert
     $this->assertEquals([$test_store2], Store::getAll());
 }
Beispiel #29
0
});
//POSTS (ADDS)
$app->post("/add_stores", function () use($app) {
    $store = Store::find($_POST['store_id']);
    $brand = Brand::find($_POST['brand_id']);
    $brand->addStore($store);
    return $app['twig']->render('brand.html.twig', array('brand' => $brand, 'brands' => Brand::getAll(), 'stores' => $brand->getStores(), 'all_stores' => Store::getAll()));
});
$app->post("/add_brands", function () use($app) {
    $store = Store::find($_POST['store_id']);
    $brand = Brand::find($_POST['brand_id']);
    $store->addBrand($brand);
    return $app['twig']->render('store.html.twig', array('store' => $store, 'stores' => Store::getAll(), 'brands' => $store->getBrands(), 'all_brands' => Brand::getAll()));
});
//GET AND EDIT AND DELETE STORE ROUTE
$app->get("/stores/{id}/edit", function ($id) use($app) {
    $store = Store::find($id);
    return $app['twig']->render('store-edit.html.twig', array('store' => $store, 'brands' => $store->getBrands()));
});
$app->patch("/stores/{id}", function ($id) use($app) {
    $store = Store::find($id);
    $new_name = $_POST['new_name'];
    $store->update($new_name);
    return $app['twig']->render('stores.html.twig', array('store' => $store, 'stores' => Store::getAll(), 'brands' => $store->getBrands()));
});
$app->delete("/stores/{id}", function ($id) use($app) {
    $store = Store::find($id);
    $store->delete();
    return $app['twig']->render('stores.html.twig', array('stores' => Store::getAll()));
});
return $app;
Beispiel #30
0
//delete shoe page
$app->get("/shoes/{id}/delete", function ($id) use($app) {
    $shoe = Shoe::find($id);
    $shoe->deleteOne();
    return $app['twig']->render('shoes.html.twig', array('shoes' => Shoe::getAll()));
});
//delete all shoes page
$app->post("/delete_shoes", function () use($app) {
    Shoe::deleteAll();
    return $app['twig']->render('index.html.twig');
});
//delete all stores page
$app->post("/delete_stores", function () use($app) {
    Store::deleteAll();
    return $app['twig']->render('index.html.twig');
});
//add shoes page
$app->post("/add_shoes", function () use($app) {
    $store = Store::find($_POST['store_id']);
    $shoe = Shoe::find($_POST['shoe_id']);
    $store->addShoe($shoe);
    return $app['twig']->render('store.html.twig', array('store' => $store, 'stores' => Store::getAll(), 'shoes' => $store->getShoes(), 'all_shoes' => Shoe::getAll()));
});
//add stores page
$app->post("/add_stores", function () use($app) {
    $store = Store::find($_POST['store_id']);
    $shoe = Shoe::find($_POST['shoe_id']);
    $shoe->addStore($store);
    return $app['twig']->render('shoe.html.twig', array('shoe' => $shoe, 'shoes' => Shoe::getAll(), 'stores' => $shoe->getStores(), 'all_stores' => Store::getAll()));
});
return $app;