function test_delete()
 {
     // arrange
     $name = "Taco Hell";
     $test_restaurant = new Restaurant($name);
     $test_restaurant->save();
     $name2 = "Puff the Magic Dragon";
     $test_restaurant2 = new Restaurant($name2);
     $test_restaurant2->save();
     // act
     $test_restaurant2->delete();
     $result = Restaurant::getAll();
     // assert
     $this->assertEquals([$test_restaurant], $result);
 }
示例#2
0
require_once "classes/Restaurant.class.php";
require_once "classes/DBUtils.class.php";
$restaurant_id = isValidID($_GET['restaurant_id']) ? $_GET['restaurant_id'] : 0;
if ($restaurant_id && !$SMObj->checkAccessLevel("EDITOR")) {
    // Figure out who the owner of this restaurant is, Editors can edit anyones items
    $sql = "SELECT restaurant_user FROM {$db_table_restaurants} WHERE restaurant_id = " . $DB_LINK->addq($restaurant_id, get_magic_quotes_gpc());
    $rc = $DB_LINK->Execute($sql);
    // If the recipe is owned by someone else then do not allow editing
    if ($rc->fields['restaurant_user'] != "" && $rc->fields['restaurant_user'] != $SMObj->getUserID()) {
        die($LangUI->_('You are not the owner of this restaurant, you are not allowed to delete it'));
    }
}
// clean up the old picture if we are suppose to
if ($g_rb_database_type == "postgres") {
    $sql = "SELECT restaurant_picture FROM {$db_table_restaurants} WHERE restaurant_id=" . $DB_LINK->addq($restaurant_id, get_magic_quotes_gpc());
    $rc = $DB_LINK->Execute($sql);
    if (trim($rc->fields['restaurant_picture']) != "") {
        $rc = $DB_LINK->BlobDelete($rc->fields['restaurant_picture']);
        DBUtils::checkResult($rc, $LangUI->_('Picture successfully deleted'), NULL, $sql);
    }
}
// In Postgres everything will be cleaned up with one delete
$RestaurantObj = new Restaurant($restaurant_id);
$RestaurantObj->delete();
?>
<I><?php 
echo $LangUI->_('Restaurant Deleted');
?>
</I>
<P>
 function test_deleteReviews()
 {
     $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_restaurant2 = new Restaurant($restaurant_name2, $location2, $description2, $price2, $cuisine_id2);
     $test_restaurant2->save();
     $user = "******";
     $stars = 3;
     $headline = "It is aight.";
     $body = "Yeah, pretty aight bro";
     $restaurant_id = $test_restaurant->getId();
     $test_review = new Review($user, $stars, $headline, $body, $restaurant_id);
     $test_review->save();
     $user2 = "6969babygirl";
     $stars2 = 3;
     $headline2 = "XOXO";
     $body2 = "I cant even";
     $restaurant_id2 = $test_restaurant->getId();
     $test_review2 = new Review($user2, $stars2, $headline2, $body2, $restaurant_id2);
     $test_review2->save();
     $test_restaurant->delete();
     $result = Review::getAll();
     //var_dump($result);
     $this->assertEquals([], $result);
 }
示例#4
0
 function test_delete()
 {
     //Arrange
     //r 1
     $test_name = "Toms Tomatos ";
     $test_seats = 15;
     $test_location = "Farmville";
     $test_evenings = true;
     $test_cuisine = new Cuisine("Mexican", true, 1);
     $test_cuisine->save();
     $test_restaurant = new Restaurant($test_name, $test_seats, $test_location, $test_evenings, $test_cuisine->getId());
     $test_restaurant->save();
     //r 2
     $test_name2 = "bobs Tomatos ";
     $test_seats2 = 13335;
     $test_location2 = "feild";
     $test_evenings2 = true;
     $test_cuisine2 = new Cuisine("Appalachian\\'s", false, 1);
     $test_cuisine2->save();
     $test_restaurant2 = new Restaurant($test_name2, $test_seats2, $test_location2, $test_evenings2, $test_cuisine2->getId());
     $test_restaurant2->save();
     //Act
     $test_restaurant2->delete();
     //Assert
     $this->assertEquals([$test_restaurant], Restaurant::getAll());
 }
 function testDelete()
 {
     //Arrange
     $name = "Pizza Party";
     $phone_number = "123-456-7890";
     $address = "1234 Pepperoni Lane";
     $id = null;
     $cuisine_id = 4;
     $test_restaurant = new Restaurant($name, $phone_number, $address, $id, $cuisine_id);
     $restaurant_id = $test_restaurant->getId();
     $test_restaurant->save();
     $name2 = "Burger Bash ";
     $test_restaurant2 = new Restaurant($name2, $phone_number, $address, $id, $cuisine_id);
     $test_restaurant2->save();
     //Act
     $test_restaurant->delete();
     //Assert
     $this->assertEquals([$test_restaurant2], Restaurant::getAll());
 }
 function test_deleteRestaurant()
 {
     //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();
     $test_restaurant = new Restaurant($id, $name, $phone, $price, $cuisine_id);
     $test_restaurant->save();
     //Act
     $test_restaurant->delete();
     //Assert
     $this->assertEquals([], Restaurant::getAll());
 }
 function testDelete()
 {
     //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();
     $restaurant2 = "HobNob";
     $address2 = "999 somewhere";
     $phone2 = "234-555-5555";
     $cuisine_id2 = $test_Cuisine->getId();
     $test_restaurant2 = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id);
     $test_restaurant2->save();
     //Act
     $test_restaurant->delete();
     //Assert
     $this->assertEquals([$test_restaurant2], Restaurant::getAll());
 }
 function test_restaurant_delete()
 {
     //Arrange
     $style = "Thai";
     $test_cuisine = new Cuisine($style);
     $test_cuisine->save();
     $name = "Pok Pok";
     $category_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($name, $category_id);
     $test_restaurant->save();
     $name2 = "Dicks";
     $category_id2 = $test_cuisine->getId();
     $test_restaurant2 = new Restaurant($name2, $category_id);
     $test_restaurant2->save();
     //Act
     $test_restaurant->delete();
     //Assert
     $this->assertEquals([$test_restaurant2], Restaurant::getAll());
 }
 function test_delete()
 {
     $address = "4234 N Interstate Ave, Portland OR 97217";
     $phone = "503-287-9740";
     $cuisine_id = 2;
     $place_name = "Happy House";
     $id = null;
     $test_restaurant = new Restaurant($place_name, $id, $address, $phone, $cuisine_id);
     $test_restaurant->save();
     $place_name2 = "Golden Dragon";
     $test_restaurant2 = new Restaurant($place_name2, $id, $address, $phone, $cuisine_id);
     $test_restaurant2->save();
     $test_restaurant->delete();
     $this->assertEquals([$test_restaurant2], Restaurant::getAll());
 }
示例#10
0
 /**
  * testBehaviorDeleteCallbacks method
  *
  * @return void
  */
 public function testBehaviorDeleteCallbacks()
 {
     $Apple = new Restaurant();
     $Apple->Behaviors->load('Test', array('beforeFind' => 'off', 'beforeDelete' => 'off'));
     $this->assertTrue($Apple->delete(6));
     $Apple->Behaviors->load('Test', array('beforeDelete' => 'on'));
     $this->assertFalse($Apple->delete(4));
     $Apple->Behaviors->load('Test', array('beforeDelete' => 'test2'));
     ob_start();
     $results = $Apple->delete(4);
     $this->assertSame(trim(ob_get_clean()), 'beforeDelete success (cascading)');
     $this->assertTrue($results);
     ob_start();
     $results = $Apple->delete(3, false);
     $this->assertSame(trim(ob_get_clean()), 'beforeDelete success');
     $this->assertTrue($results);
     $Apple->Behaviors->load('Test', array('beforeDelete' => 'off', 'afterDelete' => 'on'));
     ob_start();
     $results = $Apple->delete(2, false);
     $this->assertSame(trim(ob_get_clean()), 'afterDelete success');
     $this->assertTrue($results);
 }
 function test_Delete()
 {
     //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();
     $restaurant_name2 = "Hot Lips Pizza";
     $phone2 = '5035952342';
     $address2 = "721 NW 9th Ave #150, Portland, OR 97209";
     $website2 = "http://hotlipspizza.com/";
     $test_restaurant2 = new Restaurant($restaurant_name2, $phone2, $address2, $website2, $cuisine_id);
     $test_restaurant2->save();
     //Act
     $test_restaurant->delete();
     //Assert
     $this->assertEquals([$test_restaurant2], Restaurant::getAll());
 }
示例#12
0
 function testDelete()
 {
     //Arrange
     $type = "Tacos";
     $id = null;
     $test_cuisine = new Cuisine($type, $id);
     $test_cuisine->save();
     $name = "Nathans";
     $cuisine_id = $test_cuisine->getId();
     $price_range = 1;
     $neighborhood = "Felony Flats";
     $test_restaurant = new Restaurant($name, $id, $cuisine_id, $price_range, $neighborhood);
     $test_restaurant->save();
     $name2 = "Joses";
     $cuisine_id = $test_cuisine->getId();
     $price_range = 2;
     $neighborhood = "Buckman";
     $test_restaurant2 = new Restaurant($name2, $id, $cuisine_id, $price_range, $neighborhood);
     $test_restaurant2->save();
     //act
     $test_restaurant->delete();
     //Assert
     $this->assertEquals([$test_restaurant2], Restaurant::getAll());
 }
 function test_DeleteRestaurants()
 {
     //Arrange
     $id = null;
     $cuisine_type = "Brazilian";
     $test_cuisine_type = new Cuisine($id, $cuisine_type);
     $test_cuisine_type->save();
     $name = "Peles Brazilian Buffet";
     $phone = "510-814-2012";
     $address = "190b Mississippi St, Portland, OR 97221";
     $hours = "9am - ?";
     $test_cuisine_type_id = $test_cuisine_type->getId();
     $test_restaurant = new Restaurant($id, $name, $phone, $address, $hours, $test_cuisine_type_id);
     $test_restaurant->save();
     $name2 = "Olive Garden";
     $phone2 = "(403) 232-1091";
     $address2 = "101 Olive Garden Way, Portland, OR 97221";
     $hours2 = "8am - 10pm";
     $test_restaurant2 = new Restaurant($id, $name2, $phone2, $address2, $hours2, $test_cuisine_type_id);
     $test_restaurant2->save();
     //Act
     $test_restaurant->delete();
     //Assert
     $result = Restaurant::getAll();
     $this->assertEquals([$test_restaurant2], $result);
 }