Пример #1
0
 public function addReview($data)
 {
     $this->user_id = $data['user_id'];
     $this->restaurant_id = $data['restaurant_id'];
     $this->content = $data['content'];
     $this->rating = $data['rating'];
     $this->created_at = $data['created_at'] = date('Y-m-d H:i:s');
     $this->updated_at = $data['updated_at'] = date('Y-m-d H:i:s');
     if ($this->create($data)) {
         $restaurants = new Restaurant();
         $restaurant = $restaurants->find('id', $this->restaurant_id);
         $review_count = intval($restaurant['review_count']);
         $rating = $review_count * intval($restaurant['rating']) + intval($this->rating);
         $review_count += 1;
         $rating /= $review_count;
         $restaurants->update('id', $this->restaurant_id, ['rating' => $rating, 'review_count' => $review_count]);
         $result['status'] = "success";
         $result['success_text'] = "review added";
     } else {
         $result['status'] = "error";
         $result['error_text'] = "review not added";
     }
     return json_encode($result);
 }
 function test_update()
 {
     $name = "Asian";
     $id = null;
     $test_cuisine = new Cuisine($name, $id);
     $test_cuisine->save();
     $restaurant_name = "The Golden Duck";
     $location = "898 SW 5th Ave, Portland, OR";
     $description = "A Chill Asian experince";
     $price = "\$\$";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($restaurant_name, $location, $description, $price, $cuisine_id);
     $test_restaurant->save();
     $restaurant_name2 = "The Red Dragon";
     $location2 = "899 SW 5th Ave, Portland, OR";
     $description2 = "A Intense Asian experince";
     $price2 = "\$\$\$";
     $cuisine_id2 = $test_cuisine->getId();
     $test_restaurant->update($restaurant_name2, $location2, $description2, $price2, $cuisine_id2);
     $result = $test_restaurant->getName();
     $this->assertEquals("The Red Dragon", $result);
 }
 function testUpdate()
 {
     //Arrange
     $flavor = "Pizza";
     $id = null;
     $test_cuisine = new Cuisine($flavor, $id);
     $name = "Pizza Party";
     $phone_number = "123-456-7890";
     $address = "1234 Pepperoni Lane";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($name, $phone_number, $address, $id, $cuisine_id);
     $test_restaurant->save();
     $new_name = "Burger Bash";
     //Act
     $test_restaurant->update($new_name);
     //Assert
     $this->assertEquals("Pizza", $test_cuisine->getFlavor());
 }
 function test_update()
 {
     //Arrange
     $name = "Drinks";
     $id = null;
     $test_Cuisine = new Cuisine($name, $id);
     $test_Cuisine->save();
     $restaurant = "Aalto";
     $address = "123 Belmont";
     $phone = "123-456-7890";
     $cuisine_id = $test_Cuisine->getId();
     $test_restaurant = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id);
     $test_restaurant->save();
     $new_restaurant_name = "HobNob";
     //Act
     $test_restaurant->update($new_restaurant_name);
     //Assert
     $this->assertEquals("HobNob", $test_restaurant->getName());
 }
 function testUpdate()
 {
     //Arrange
     $type = "french";
     $id = null;
     $test_cuisine = new Cuisine($type, $id);
     $test_cuisine->save();
     $name = "Petit Provence";
     $phone = "555-555-5555";
     $price = "\$\$";
     $cuisine_id = $test_cuisine->getId();
     // $id = null;
     $test_restaurant = new Restaurant($name, $phone, $price, $cuisine_id);
     $test_restaurant->save();
     $new_name = "Escargot";
     $new_phone = "666-666-6666";
     $new_price = "\$\$\$";
     // $cuisine_id = 1;
     // $new_id = null;
     $new_test_restaurant = new Restaurant($new_name, $new_phone, $new_price, $cuisine_id, $test_restaurant->getId());
     // $new_test_restaurant->save();
     // var_dump($new_test_restaurant);
     //Act
     $test_restaurant->update($new_name, $new_phone, $new_price);
     //Assert
     $this->assertEquals($test_restaurant, $new_test_restaurant);
 }
Пример #6
0
<?php

require_once 'model/session.php';
require_once 'model/order.php';
require_once 'model/restaurant.php';
$session = new Session();
$order = new Order();
$restaurant = new Restaurant();
if ($session->get_session_data('user_type') == 'admin') {
    $restaurant->update('id', $_GET['id'], ['status' => 1]);
    header('Location: admin-dashboard.php');
} else {
    print_r("Something went wrong");
}
Пример #7
0
 function test_update()
 {
     $name = "Chinese";
     $id = null;
     $test_cuisine = new Cuisine($name, $id);
     $test_cuisine->save();
     $place_name = "Happy House";
     $address = "4234 N Interstate Ave, Portland OR 97217";
     $phone = "503-287-9740";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($place_name, $id, $address, $phone, $cuisine_id);
     $test_restaurant->save();
     $new_place_name = "Very Happy House";
     $new_address = "5000 N Interstate Ave, Portland OR 97217";
     $new_phone = "503-287-9000";
     $test_restaurant->update($new_place_name, $new_address, $new_phone);
     $this->assertEquals("Very Happy House", $test_restaurant->getPlaceName());
     $this->assertEquals("5000 N Interstate Ave, Portland OR 97217", $test_restaurant->getAddress());
     $this->assertEquals("503-287-9000", $test_restaurant->getPhone());
 }
Пример #8
0
 function test_Update()
 {
     //Arrange
     $name = "American";
     $id = null;
     $test_cuisine = new Cuisine($name, $id);
     $test_cuisine->save();
     $restaurant_name = "VQ";
     $phone = '5032277342';
     $address = "1220 SW 1st Ave, Portland, OR 97204";
     $website = "http://www.veritablequandary.com/";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($restaurant_name, $phone, $address, $website, $cuisine_id);
     $test_restaurant->save();
     $column_to_update = "restaurant_name";
     $new_information = "Veritable Quandary";
     //Act
     $test_restaurant->update($column_to_update, $new_information);
     //Assert
     $result = Restaurant::getAll();
     $this->assertEquals("Veritable Quandary", $result[0]->getRestaurantName());
 }
Пример #9
0
 function testUpdate()
 {
     //Arrange
     $restaurant_name = "Joes Burgers";
     $id = null;
     $test_restaurant = new Restaurant($restaurant_name, $id);
     $test_restaurant->save();
     $new_restaurant_name = "McDonalds";
     //Act
     $test_restaurant->update($new_restaurant_name);
     //Assert
     $this->assertEquals($new_restaurant_name, $test_restaurant->getRestaurantName());
 }
 function test_update()
 {
     //Arrange
     $cuisine_type = "Italian";
     $id = null;
     $test_cuisine = new Cuisine($cuisine_type, $id);
     $test_cuisine->save();
     $name = "Taco Restaurant";
     $phone = "(503) 777-9097";
     $address = "7000 Beaverton Hillsdale HWY, Portland, OR 97221";
     $hours = "7am - 2am";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($id, $name, $phone, $address, $hours, $cuisine_id);
     $test_restaurant->save();
     $new_name = "Taco Bell";
     // $new_phone = "(402) 231-0911";
     // $new_address = "902 Beaverton Hillsdale Hwy, Portland, OR 97211";
     // $new_hours = "8am - 10pm";
     //Act
     $test_restaurant->update($new_name);
     //Assert
     $this->assertEquals("Taco Bell", $test_restaurant->getName());
 }