/** * test for sorting all products * NOTE: By changing the any product in the database or adding any product * this test will no longer work unless $expectedResult is changed * based on AdminSearch::sortProduct's new output */ public function testSortProduct() { // Arrange $adminSearch = new AdminSearch(); $connection = open_database_connection(); $expectedResult = '<form id="productResult20" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult20\').submit();">Alfalfa Sprouts </span> - These sprouts are a perfect match for any vegetarian burger. It is a light a refreshing topping for your burger and a great source of iron for your diet.</p><p>Calories: 120</p><p>Price: 1.19</p><input type="hidden" name="product_ID" value="20" /><input type="hidden" name="product_name" value="Alfalfa Sprouts " /><input type="hidden" name="product_image_URL" value="alfalfa_sprouts.png" /><input type="hidden" name="product_description" value="These sprouts are a perfect match for any vegetarian burger. It is a light a refreshing topping for your burger and a great source of iron for your diet." /><input type="hidden" name="product_calories" value="120" /><input type="hidden" name="product_allergy_info" value="None" /><input type="hidden" name="product_price" value="1.19" /><input type="hidden" name="category_ID" value="5" /><input type="hidden" name="category_name" value="Extra Burger Toppings" /><input type="hidden" name="category_summary" value="Try and add a little extra to your burger by adding one of these extra toppings meant to add a special touch to your meal. You will be glad and always come back to it or try a different one next time!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="alfalfa_sprouts.png" /></form><form id="productResult1" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult1\').submit();">Backyard Burger</span> - A delicious vegetable burger made with wholemeal flour buns, ring sliced red onion, organic tomato slices, cheddar cheese, pickles, ketchup and crisp salad.</p><p>Calories: 435</p><p>Price: 7.95</p><input type="hidden" name="product_ID" value="1" /><input type="hidden" name="product_name" value="Backyard Burger" /><input type="hidden" name="product_image_URL" value="backyard_burger.png" /><input type="hidden" name="product_description" value="A delicious vegetable burger made with wholemeal flour buns, ring sliced red onion, organic tomato slices, cheddar cheese, pickles, ketchup and crisp salad." /><input type="hidden" name="product_calories" value="435" /><input type="hidden" name="product_allergy_info" value="This product might contain nuts" /><input type="hidden" name="product_price" value="7.95" /><input type="hidden" name="category_ID" value="1" /><input type="hidden" name="category_name" value="Vegetarian Burgers" /><input type="hidden" name="category_summary" value="Freshly made selection of vegetarian burgers and sandwiches using the finest ingredients available today. Try one and you will want more!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="backyard_burger.png" /></form><form id="productResult11" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult11\').submit();">Black Tea</span> - KBK serves a classic flavoured black tea known as Earl Grey which is flavoured with bergamot essential oil or citrus flavour. It is a long term perfect companion for a quiet afternoon or while browsing a family photo album. Experience the magic of a cup of KBK black tea!</p><p>Calories: 2</p><p>Price: 2.25</p><input type="hidden" name="product_ID" value="11" /><input type="hidden" name="product_name" value="Black Tea" /><input type="hidden" name="product_image_URL" value="black_tea.png" /><input type="hidden" name="product_description" value="KBK serves a classic flavoured black tea known as Earl Grey which is flavoured with bergamot essential oil or citrus flavour. It is a long term perfect companion for a quiet afternoon or while browsing a family photo album. Experience the magic of a cup of KBK black tea!" /><input type="hidden" name="product_calories" value="2" /><input type="hidden" name="product_allergy_info" value="there are no known allergens for this drink" /><input type="hidden" name="product_price" value="2.25" /><input type="hidden" name="category_ID" value="3" /><input type="hidden" name="category_name" value="Drinks" /><input type="hidden" name="category_summary" value="Quench your thirst with our selection of freshly made drinks or warm yourself up with a selection of hot drinks that we offer!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="black_tea.png" /></form><form id="productResult13" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult13\').submit();">Cappuccino</span> - This creamy, delicious, rich flavoured coffee specialty is made from 1/3 Espresso, 1/3 steamed milk and 1/3 foamed milk and garnished with your choice of Cinnamon or powder chocolate. We use high altitude(above 3000 ft) grown Arabica coffee beans.</p><p>Calories: 115</p><p>Price: 3.45</p><input type="hidden" name="product_ID" value="13" /><input type="hidden" name="product_name" value="Cappuccino" /><input type="hidden" name="product_image_URL" value="cappuccino.png" /><input type="hidden" name="product_description" value="This creamy, delicious, rich flavoured coffee specialty is made from 1/3 Espresso, 1/3 steamed milk and 1/3 foamed milk and garnished with your choice of Cinnamon or powder chocolate. We use high altitude(above 3000 ft) grown Arabica coffee beans." /><input type="hidden" name="product_calories" value="115" /><input type="hidden" name="product_allergy_info" value="no allergens are present on this drink product but consideration for those with low toleration to milk products should be given." /><input type="hidden" name="product_price" value="3.45" /><input type="hidden" name="category_ID" value="3" /><input type="hidden" name="category_name" value="Drinks" /><input type="hidden" name="category_summary" value="Quench your thirst with our selection of freshly made drinks or warm yourself up with a selection of hot drinks that we offer!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="cappuccino.png" /></form><form id="productResult15" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult15\').submit();">Chocolate Cheesecake</span> - This chocolate cheesecake is made to excellence by our chefs to satisfy the most critic connoisseurs. It has a fine and subtle vanilla taste and its topped with raspberries and chocolate curls to accomplish an unforgettable experience! </p><p>Calories: 580</p><p>Price: 5.95</p><input type="hidden" name="product_ID" value="15" /><input type="hidden" name="product_name" value="Chocolate Cheesecake" /><input type="hidden" name="product_image_URL" value="chocolate_cheesecake.png" /><input type="hidden" name="product_description" value="This chocolate cheesecake is made to excellence by our chefs to satisfy the most critic connoisseurs. It has a fine and subtle vanilla taste and its topped with raspberries and chocolate curls to accomplish an unforgettable experience! " /><input type="hidden" name="product_calories" value="580" /><input type="hidden" name="product_allergy_info" value="this product contain traces of nuts" /><input type="hidden" name="product_price" value="5.95" /><input type="hidden" name="category_ID" value="4" /><input type="hidden" name="category_name" value="Desserts" /><input type="hidden" name="category_summary" value="From a range of fresh donuts to a mouth watering pumpkin pie or strawberry cheesecake, there is something for everyone!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="chocolate_cheesecake.png" /></form><form id="productResult26" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult26\').submit();">Chocolate Pudding</span> - This sweet and tasty chocolate pudding is a good source of antioxidants and the cocoa gives you 10% of your daily recommended allowance of iron. Topped up with fresh raspberries makes it the most popular KBK dessert so far!</p><p>Calories: 220</p><p>Price: 2.99</p><input type="hidden" name="product_ID" value="26" /><input type="hidden" name="product_name" value="Chocolate Pudding" /><input type="hidden" name="product_image_URL" value="chocolate_pudding.png" /><input type="hidden" name="product_description" value="This sweet and tasty chocolate pudding is a good source of antioxidants and the cocoa gives you 10% of your daily recommended allowance of iron. Topped up with fresh raspberries makes it the most popular KBK dessert so far!" /><input type="hidden" name="product_calories" value="220" /><input type="hidden" name="product_allergy_info" value="Contains nuts and milk based products." /><input type="hidden" name="product_price" value="2.99" /><input type="hidden" name="category_ID" value="4" /><input type="hidden" name="category_name" value="Desserts" /><input type="hidden" name="category_summary" value="From a range of fresh donuts to a mouth watering pumpkin pie or strawberry cheesecake, there is something for everyone!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="chocolate_pudding.png" /></form><form id="productResult22" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult22\').submit();">Cranberry Sauce</span> - Did you ever think of adding Cranberry Sauce to your vegetarian burger? If not, you will be amazed at what an experience to your palate this can offer by adding a little extra sweetness to your already delicious choice of KBK burger!</p><p>Calories: 90</p><p>Price: 0.49</p><input type="hidden" name="product_ID" value="22" /><input type="hidden" name="product_name" value="Cranberry Sauce" /><input type="hidden" name="product_image_URL" value="cranberry_sauce.png" /><input type="hidden" name="product_description" value="Did you ever think of adding Cranberry Sauce to your vegetarian burger? If not, you will be amazed at what an experience to your palate this can offer by adding a little extra sweetness to your already delicious choice of KBK burger!" /><input type="hidden" name="product_calories" value="90" /><input type="hidden" name="product_allergy_info" value="None" /><input type="hidden" name="product_price" value="0.49" /><input type="hidden" name="category_ID" value="5" /><input type="hidden" name="category_name" value="Extra Burger Toppings" /><input type="hidden" name="category_summary" value="Try and add a little extra to your burger by adding one of these extra toppings meant to add a special touch to your meal. You will be glad and always come back to it or try a different one next time!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="cranberry_sauce.png" /></form><form id="productResult9" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult9\').submit();">Fresh Orange juice</span> - Our KBK orange juice is made fresh in house from squeezing 4 whole sun kissed Florida oranges. A truly energizing drink full of life and vitamin C.</p><p>Calories: 120</p><p>Price: 3.95</p><input type="hidden" name="product_ID" value="9" /><input type="hidden" name="product_name" value="Fresh Orange juice" /><input type="hidden" name="product_image_URL" value="orange_juice.png" /><input type="hidden" name="product_description" value="Our KBK orange juice is made fresh in house from squeezing 4 whole sun kissed Florida oranges. A truly energizing drink full of life and vitamin C." /><input type="hidden" name="product_calories" value="120" /><input type="hidden" name="product_allergy_info" value="No allergens present" /><input type="hidden" name="product_price" value="3.95" /><input type="hidden" name="category_ID" value="3" /><input type="hidden" name="category_name" value="Drinks" /><input type="hidden" name="category_summary" value="Quench your thirst with our selection of freshly made drinks or warm yourself up with a selection of hot drinks that we offer!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="orange_juice.png" /></form><form id="productResult23" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult23\').submit();">Fried Green Tomatoes </span> - They are not just crunchy but juicy on the inside and a different experience to the ordinary tomatoes. Try one today!</p><p>Calories: 185</p><p>Price: 1.79</p><input type="hidden" name="product_ID" value="23" /><input type="hidden" name="product_name" value="Fried Green Tomatoes " /><input type="hidden" name="product_image_URL" value="fried_green_tomatoes.png" /><input type="hidden" name="product_description" value="They are not just crunchy but juicy on the inside and a different experience to the ordinary tomatoes. Try one today!" /><input type="hidden" name="product_calories" value="185" /><input type="hidden" name="product_allergy_info" value="May contain gluten and traces of nuts" /><input type="hidden" name="product_price" value="1.79" /><input type="hidden" name="category_ID" value="5" /><input type="hidden" name="category_name" value="Extra Burger Toppings" /><input type="hidden" name="category_summary" value="Try and add a little extra to your burger by adding one of these extra toppings meant to add a special touch to your meal. You will be glad and always come back to it or try a different one next time!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="fried_green_tomatoes.png" /></form><form id="productResult5" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult5\').submit();">Garden Salad</span> - Our house garden salad is a mixture of specially selected lettuces blending in harmony with juicy tomatoes, three-style-cheese, crispy croutons and our KBK salad dressing.</p><p>Calories: 220</p><p>Price: 4.95</p><input type="hidden" name="product_ID" value="5" /><input type="hidden" name="product_name" value="Garden Salad" /><input type="hidden" name="product_image_URL" value="garden_salad.png" /><input type="hidden" name="product_description" value="Our house garden salad is a mixture of specially selected lettuces blending in harmony with juicy tomatoes, three-style-cheese, crispy croutons and our KBK salad dressing." /><input type="hidden" name="product_calories" value="220" /><input type="hidden" name="product_allergy_info" value="No allergens present" /><input type="hidden" name="product_price" value="4.95" /><input type="hidden" name="category_ID" value="2" /><input type="hidden" name="category_name" value="Salads" /><input type="hidden" name="category_summary" value="A healthy menu item that can be enjoyed in any season and has the benefit of low calories and a good source of energy. Our range of salads are carefully prepared from fresh leaves on the day it is served." /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="garden_salad.png" /></form><form id="productResult25" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult25\').submit();">Goat Cheese Leafy Salad </span> - A marvellous collection of salad leafs, spinach, nuts and topped up with selected goat cheese dressed with vinaigrette dressing.</p><p>Calories: 130</p><p>Price: 2.29</p><input type="hidden" name="product_ID" value="25" /><input type="hidden" name="product_name" value="Goat Cheese Leafy Salad " /><input type="hidden" name="product_image_URL" value="goat_cheese_salad.png" /><input type="hidden" name="product_description" value="A marvellous collection of salad leafs, spinach, nuts and topped up with selected goat cheese dressed with vinaigrette dressing." /><input type="hidden" name="product_calories" value="130" /><input type="hidden" name="product_allergy_info" value="Contains milk based products, seeds, and nuts." /><input type="hidden" name="product_price" value="2.29" /><input type="hidden" name="category_ID" value="2" /><input type="hidden" name="category_name" value="Salads" /><input type="hidden" name="category_summary" value="A healthy menu item that can be enjoyed in any season and has the benefit of low calories and a good source of energy. Our range of salads are carefully prepared from fresh leaves on the day it is served." /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="goat_cheese_salad.png" /></form><form id="productResult3" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult3\').submit();">Jimmy John Sandwich</span> - This delicious vegetarian sandwich is made from layers of provolone cheese separated by real avocado spread, tomato and mayonnaise, sliced cucumber and lettuce.</p><p>Calories: 784</p><p>Price: 6.85</p><input type="hidden" name="product_ID" value="3" /><input type="hidden" name="product_name" value="Jimmy John Sandwich" /><input type="hidden" name="product_image_URL" value="jimmy_john_sandwich.png" /><input type="hidden" name="product_description" value="This delicious vegetarian sandwich is made from layers of provolone cheese separated by real avocado spread, tomato and mayonnaise, sliced cucumber and lettuce." /><input type="hidden" name="product_calories" value="784" /><input type="hidden" name="product_allergy_info" value="Sandwich bread may contain traces of nuts" /><input type="hidden" name="product_price" value="6.85" /><input type="hidden" name="category_ID" value="1" /><input type="hidden" name="category_name" value="Vegetarian Burgers" /><input type="hidden" name="category_summary" value="Freshly made selection of vegetarian burgers and sandwiches using the finest ingredients available today. Try one and you will want more!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="jimmy_john_sandwich.png" /></form><form id="productResult16" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult16\').submit();">KBK Donuts</span> - Our donuts make a perfect dessert choice for the sweet lovers. Topped up with different toppings including chocolate, glazed, powdered sugar, cinnamon, vanilla or strawberry frosted, there is one for everyone!</p><p>Calories: 350</p><p>Price: 4.85</p><input type="hidden" name="product_ID" value="16" /><input type="hidden" name="product_name" value="KBK Donuts" /><input type="hidden" name="product_image_URL" value="donuts.png" /><input type="hidden" name="product_description" value="Our donuts make a perfect dessert choice for the sweet lovers. Topped up with different toppings including chocolate, glazed, powdered sugar, cinnamon, vanilla or strawberry frosted, there is one for everyone!" /><input type="hidden" name="product_calories" value="350" /><input type="hidden" name="product_allergy_info" value="Contains milk, wheat and soy." /><input type="hidden" name="product_price" value="4.85" /><input type="hidden" name="category_ID" value="4" /><input type="hidden" name="category_name" value="Desserts" /><input type="hidden" name="category_summary" value="From a range of fresh donuts to a mouth watering pumpkin pie or strawberry cheesecake, there is something for everyone!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="donuts.png" /></form><form id="productResult24" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult24\').submit();">KBK House Burger</span> - Steamed cooked baby potatoes cooked to perfection with magic KBK spices, house made buns with pumpkin seeds, lettuce, sun dried tomatoes and mayo, peas and fine chopped green onions are just the companion for this delicious mild spiced vegetarian burger proudly made by KBK.</p><p>Calories: 480</p><p>Price: 6.49</p><input type="hidden" name="product_ID" value="24" /><input type="hidden" name="product_name" value="KBK House Burger" /><input type="hidden" name="product_image_URL" value="kbk_house_burger.png" /><input type="hidden" name="product_description" value="Steamed cooked baby potatoes cooked to perfection with magic KBK spices, house made buns with pumpkin seeds, lettuce, sun dried tomatoes and mayo, peas and fine chopped green onions are just the companion for this delicious mild spiced vegetarian burger proudly made by KBK." /><input type="hidden" name="product_calories" value="480" /><input type="hidden" name="product_allergy_info" value="Contains seeds. May contain gluten and traces of nuts." /><input type="hidden" name="product_price" value="6.49" /><input type="hidden" name="category_ID" value="1" /><input type="hidden" name="category_name" value="Vegetarian Burgers" /><input type="hidden" name="category_summary" value="Freshly made selection of vegetarian burgers and sandwiches using the finest ingredients available today. Try one and you will want more!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="kbk_house_burger.png" /></form><form id="productResult10" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult10\').submit();">Lemon Tea</span> - KBK lemon tea is inspired from the Indian cuisine and it is a very refreshing drink which could be served at any time of the day indulging yourself or when meeting with your next door neighbor. It is made of aromatic Indian black tea, lemon, and spring water. Best served with a slice of lemon and some ice!</p><p>Calories: 40</p><p>Price: 2.95</p><input type="hidden" name="product_ID" value="10" /><input type="hidden" name="product_name" value="Lemon Tea" /><input type="hidden" name="product_image_URL" value="lemon_tea.png" /><input type="hidden" name="product_description" value="KBK lemon tea is inspired from the Indian cuisine and it is a very refreshing drink which could be served at any time of the day indulging yourself or when meeting with your next door neighbor. It is made of aromatic Indian black tea, lemon, and spring water. Best served with a slice of lemon and some ice!" /><input type="hidden" name="product_calories" value="40" /><input type="hidden" name="product_allergy_info" value="no allergens are present on this product." /><input type="hidden" name="product_price" value="2.95" /><input type="hidden" name="category_ID" value="3" /><input type="hidden" name="category_name" value="Drinks" /><input type="hidden" name="category_summary" value="Quench your thirst with our selection of freshly made drinks or warm yourself up with a selection of hot drinks that we offer!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="lemon_tea.png" /></form><form id="productResult14" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult14\').submit();">Mineral Water</span> - This mineral water is bottled fresh at its source in the French Alps. You are what you drink, so hydration is very important, so do not leave out this vital supplement in any meal.</p><p>Calories: 10</p><p>Price: 1.49</p><input type="hidden" name="product_ID" value="14" /><input type="hidden" name="product_name" value="Mineral Water" /><input type="hidden" name="product_image_URL" value="mineral_water.png" /><input type="hidden" name="product_description" value="This mineral water is bottled fresh at its source in the French Alps. You are what you drink, so hydration is very important, so do not leave out this vital supplement in any meal." /><input type="hidden" name="product_calories" value="10" /><input type="hidden" name="product_allergy_info" value="None" /><input type="hidden" name="product_price" value="1.49" /><input type="hidden" name="category_ID" value="3" /><input type="hidden" name="category_name" value="Drinks" /><input type="hidden" name="category_summary" value="Quench your thirst with our selection of freshly made drinks or warm yourself up with a selection of hot drinks that we offer!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="mineral_water.png" /></form><form id="productResult21" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult21\').submit();">Potato Chips</span> - The crisp and crunchy texture of the potato chips is what makes your burger special. They came in two flavours on our menu: spicy and barbecue.</p><p>Calories: 160</p><p>Price: 1.39</p><input type="hidden" name="product_ID" value="21" /><input type="hidden" name="product_name" value="Potato Chips" /><input type="hidden" name="product_image_URL" value="chips.png" /><input type="hidden" name="product_description" value="The crisp and crunchy texture of the potato chips is what makes your burger special. They came in two flavours on our menu: spicy and barbecue." /><input type="hidden" name="product_calories" value="160" /><input type="hidden" name="product_allergy_info" value="May contain traces of nuts" /><input type="hidden" name="product_price" value="1.39" /><input type="hidden" name="category_ID" value="5" /><input type="hidden" name="category_name" value="Extra Burger Toppings" /><input type="hidden" name="category_summary" value="Try and add a little extra to your burger by adding one of these extra toppings meant to add a special touch to your meal. You will be glad and always come back to it or try a different one next time!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="chips.png" /></form><form id="productResult17" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult17\').submit();">Pumpkin Pie</span> - The traditional KBK pumpkin pie is made from a blend of three different types of organic pumpkin made into a smooth puree and baked to perfection in house giving a fine crust and a distinct taste. A must try in the autumn from Halloween through Christmas season!</p><p>Calories: 320</p><p>Price: 3.65</p><input type="hidden" name="product_ID" value="17" /><input type="hidden" name="product_name" value="Pumpkin Pie" /><input type="hidden" name="product_image_URL" value="dessert.png" /><input type="hidden" name="product_description" value="The traditional KBK pumpkin pie is made from a blend of three different types of organic pumpkin made into a smooth puree and baked to perfection in house giving a fine crust and a distinct taste. A must try in the autumn from Halloween through Christmas season!" /><input type="hidden" name="product_calories" value="320" /><input type="hidden" name="product_allergy_info" value="contain traces of soy, nuts as well as milk." /><input type="hidden" name="product_price" value="3.65" /><input type="hidden" name="category_ID" value="4" /><input type="hidden" name="category_name" value="Desserts" /><input type="hidden" name="category_summary" value="From a range of fresh donuts to a mouth watering pumpkin pie or strawberry cheesecake, there is something for everyone!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="dessert.png" /></form><form id="productResult6" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult6\').submit();">Queen Salad</span> - Our KBK Queen salad is made of carefully chopped lettuce, mixed with tiny tomatoes, leafy greens, spinach,cheddar cheese, finely sliced red cabbage, avocado and dressed with apple cider vinegar.</p><p>Calories: 280</p><p>Price: 4.65</p><input type="hidden" name="product_ID" value="6" /><input type="hidden" name="product_name" value="Queen Salad" /><input type="hidden" name="product_image_URL" value="queen_salad.png" /><input type="hidden" name="product_description" value="Our KBK Queen salad is made of carefully chopped lettuce, mixed with tiny tomatoes, leafy greens, spinach,cheddar cheese, finely sliced red cabbage, avocado and dressed with apple cider vinegar." /><input type="hidden" name="product_calories" value="280" /><input type="hidden" name="product_allergy_info" value="No allergens present" /><input type="hidden" name="product_price" value="4.65" /><input type="hidden" name="category_ID" value="2" /><input type="hidden" name="category_name" value="Salads" /><input type="hidden" name="category_summary" value="A healthy menu item that can be enjoyed in any season and has the benefit of low calories and a good source of energy. Our range of salads are carefully prepared from fresh leaves on the day it is served." /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="queen_salad.png" /></form><form id="productResult2" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult2\').submit();">Red Robin Vegetarian Burger</span> - The Red Robin Vegetarian burger is topped with lettuce, pickles, tomatoes and our Country Dijon sauce on a lovely whole-grain bun!</p><p>Calories: 795</p><p>Price: 7.95</p><input type="hidden" name="product_ID" value="2" /><input type="hidden" name="product_name" value="Red Robin Vegetarian Burger" /><input type="hidden" name="product_image_URL" value="red_robin_burger.png" /><input type="hidden" name="product_description" value="The Red Robin Vegetarian burger is topped with lettuce, pickles, tomatoes and our Country Dijon sauce on a lovely whole-grain bun!" /><input type="hidden" name="product_calories" value="795" /><input type="hidden" name="product_allergy_info" value="May contain traces of nuts" /><input type="hidden" name="product_price" value="7.95" /><input type="hidden" name="category_ID" value="1" /><input type="hidden" name="category_name" value="Vegetarian Burgers" /><input type="hidden" name="category_summary" value="Freshly made selection of vegetarian burgers and sandwiches using the finest ingredients available today. Try one and you will want more!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="red_robin_burger.png" /></form><form id="productResult18" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult18\').submit();">Strawberry Cheesecake</span> - This is a classic, delicious cheesecake made from a vanilla spongecake bottom with fresh strawberries baked throughout and Greek style natural yogurt. This symbolises a true piece of culinary art in baking cheesecake. One that we recommend!</p><p>Calories: 268</p><p>Price: 3.95</p><input type="hidden" name="product_ID" value="18" /><input type="hidden" name="product_name" value="Strawberry Cheesecake" /><input type="hidden" name="product_image_URL" value="strawberry_cheesecake.png" /><input type="hidden" name="product_description" value="This is a classic, delicious cheesecake made from a vanilla spongecake bottom with fresh strawberries baked throughout and Greek style natural yogurt. This symbolises a true piece of culinary art in baking cheesecake. One that we recommend!" /><input type="hidden" name="product_calories" value="268" /><input type="hidden" name="product_allergy_info" value="this product may contain gluten and nuts and also contains milk." /><input type="hidden" name="product_price" value="3.95" /><input type="hidden" name="category_ID" value="4" /><input type="hidden" name="category_name" value="Desserts" /><input type="hidden" name="category_summary" value="From a range of fresh donuts to a mouth watering pumpkin pie or strawberry cheesecake, there is something for everyone!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="strawberry_cheesecake.png" /></form><form id="productResult12" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult12\').submit();">Tomato juice</span> - We are taking pride in presenting this healthy tomato juice drink as we have our own source of organic tomatoes. The difference in our juice is the low salt content which mixed with the lycopene content (an antioxidant that may help with lowering the risk of some serious health conditions) makes a good choice for a side drink on the vegetarian KBK range of burgers.</p><p>Calories: 21</p><p>Price: 2.45</p><input type="hidden" name="product_ID" value="12" /><input type="hidden" name="product_name" value="Tomato juice" /><input type="hidden" name="product_image_URL" value="tomato_juice.png" /><input type="hidden" name="product_description" value="We are taking pride in presenting this healthy tomato juice drink as we have our own source of organic tomatoes. The difference in our juice is the low salt content which mixed with the lycopene content (an antioxidant that may help with lowering the risk of some serious health conditions) makes a good choice for a side drink on the vegetarian KBK range of burgers." /><input type="hidden" name="product_calories" value="21" /><input type="hidden" name="product_allergy_info" value="not suitable for people with allergy to latex or people with allergy to potatoes or tobacco." /><input type="hidden" name="product_price" value="2.45" /><input type="hidden" name="category_ID" value="3" /><input type="hidden" name="category_name" value="Drinks" /><input type="hidden" name="category_summary" value="Quench your thirst with our selection of freshly made drinks or warm yourself up with a selection of hot drinks that we offer!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="tomato_juice.png" /></form><form id="productResult7" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult7\').submit();">Traditional Salad</span> - Our traditional KBK salad is made of mixed green and red leaves, cherry tomatoes, spinach, avocado and dressed with our premium vinaigrette dressing.</p><p>Calories: 230</p><p>Price: 4.45</p><input type="hidden" name="product_ID" value="7" /><input type="hidden" name="product_name" value="Traditional Salad" /><input type="hidden" name="product_image_URL" value="salad.png" /><input type="hidden" name="product_description" value="Our traditional KBK salad is made of mixed green and red leaves, cherry tomatoes, spinach, avocado and dressed with our premium vinaigrette dressing." /><input type="hidden" name="product_calories" value="230" /><input type="hidden" name="product_allergy_info" value="No allergens present" /><input type="hidden" name="product_price" value="4.45" /><input type="hidden" name="category_ID" value="2" /><input type="hidden" name="category_name" value="Salads" /><input type="hidden" name="category_summary" value="A healthy menu item that can be enjoyed in any season and has the benefit of low calories and a good source of energy. Our range of salads are carefully prepared from fresh leaves on the day it is served." /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="salad.png" /></form><form id="productResult19" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult19\').submit();">Tzatziki</span> - Alternative to mayo on your vegetarian burger, glamorous taste with added garlic and cucumber. Great companion to feta cheese and Kalamata olive tapenade.</p><p>Calories: 140</p><p>Price: 0.49</p><input type="hidden" name="product_ID" value="19" /><input type="hidden" name="product_name" value="Tzatziki" /><input type="hidden" name="product_image_URL" value="tzatziki.png" /><input type="hidden" name="product_description" value="Alternative to mayo on your vegetarian burger, glamorous taste with added garlic and cucumber. Great companion to feta cheese and Kalamata olive tapenade." /><input type="hidden" name="product_calories" value="140" /><input type="hidden" name="product_allergy_info" value="Milk" /><input type="hidden" name="product_price" value="0.49" /><input type="hidden" name="category_ID" value="5" /><input type="hidden" name="category_name" value="Extra Burger Toppings" /><input type="hidden" name="category_summary" value="Try and add a little extra to your burger by adding one of these extra toppings meant to add a special touch to your meal. You will be glad and always come back to it or try a different one next time!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="tzatziki.png" /></form><form id="productResult4" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult4\').submit();">Vegetarian Burger</span> - Our home made vegetarian burger is made with organic fresh vegetables including freshly cut lettuce, white onions, succulent tomatoes, pickles mayonnaise and ketchup served on a toasted sesame seed bun.</p><p>Calories: 640</p><p>Price: 8.95</p><input type="hidden" name="product_ID" value="4" /><input type="hidden" name="product_name" value="Vegetarian Burger" /><input type="hidden" name="product_image_URL" value="vegetarian_burger.png" /><input type="hidden" name="product_description" value="Our home made vegetarian burger is made with organic fresh vegetables including freshly cut lettuce, white onions, succulent tomatoes, pickles mayonnaise and ketchup served on a toasted sesame seed bun." /><input type="hidden" name="product_calories" value="640" /><input type="hidden" name="product_allergy_info" value="Buns may contain traces of nuts" /><input type="hidden" name="product_price" value="8.95" /><input type="hidden" name="category_ID" value="1" /><input type="hidden" name="category_name" value="Vegetarian Burgers" /><input type="hidden" name="category_summary" value="Freshly made selection of vegetarian burgers and sandwiches using the finest ingredients available today. Try one and you will want more!" /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="vegetarian_burger.png" /></form><form id="productResult8" action= "/adminEditProduct" method="get"> <p><span class="search" onclick="document.getElementById(\'productResult8\').submit();">Veggie Delight Salad</span> - The veggie delight salad offers an abundance of energy from its ingredients such as round sliced organic cucumbers and tomatoes, green peppers and red onion on a bed of finely chopped crisp lettuce dressed with lemon dressing.</p><p>Calories: 345</p><p>Price: 4.75</p><input type="hidden" name="product_ID" value="8" /><input type="hidden" name="product_name" value="Veggie Delight Salad" /><input type="hidden" name="product_image_URL" value="veggie_delight_salad.png" /><input type="hidden" name="product_description" value="The veggie delight salad offers an abundance of energy from its ingredients such as round sliced organic cucumbers and tomatoes, green peppers and red onion on a bed of finely chopped crisp lettuce dressed with lemon dressing." /><input type="hidden" name="product_calories" value="345" /><input type="hidden" name="product_allergy_info" value="No allergens found" /><input type="hidden" name="product_price" value="4.75" /><input type="hidden" name="category_ID" value="2" /><input type="hidden" name="category_name" value="Salads" /><input type="hidden" name="category_summary" value="A healthy menu item that can be enjoyed in any season and has the benefit of low calories and a good source of energy. Our range of salads are carefully prepared from fresh leaves on the day it is served." /><input type="hidden" name="productImageURL1" value="" /><input type="hidden" name="productImageURL2" value="veggie_delight_salad.png" /></form>'; // Assert $result = $adminSearch->sortProduct($connection, "ProductName", "ASC"); close_database_connection($connection); // Act $this->assertEquals($result, $expectedResult); }
/** * Search action for the admin pages. This function handles all of the possible * types of searches that the user might search for. * * Action for route: /adminSearch * * @param Request $request * @param Application $app * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function searchAction(Request $request, Application $app) { // test if 'username' stored in session ... $username = getAuthenticatedUserName($app); // check we are authenticated -------- $isAuthenticated = null != $username; if (!$isAuthenticated) { // not authenticated, so redirect to LOGIN page return $app->redirect('/login'); } $connection = open_database_connection(); $searchType = $_GET['search_type']; if ($searchType == "new") { $searchType = "product"; } $searchObject = new AdminSearch(); $searchResults = ""; if ($searchType == "category") { if (!empty($_GET['keywords'])) { if (isset($_GET['name'])) { if ($_GET['name'] == "ascending") { $searchResults = $searchObject->sortCategoryBySearch($connection, "ASC", "CategoryName", $_GET['keywords']); } else { if ($_GET['name'] == "descending") { $searchResults = $searchObject->sortCategoryBySearch($connection, "DESC", "CategoryName", $_GET['keywords']); } } } else { $searchResults = $searchObject->makeCategorySearch($connection, $_GET['keywords']); } } else { if (isset($_GET['name'])) { if ($_GET['name'] == "ascending") { $searchResults = $searchObject->sortCategory($connection, "CategoryName", "ASC"); } else { $searchResults = $searchObject->sortCategory($connection, "CategoryName", "DESC"); } } else { if (isset($_GET['summary'])) { if ($_GET['summary'] == "ascending") { $searchResults = $searchObject->sortCategory($connection, "CategorySummary", "ASC"); } else { $searchResults = $searchObject->sortCategory($connection, "CategorySummary", "DESC"); } } } } } else { if ($searchType == "product-category") { if (isset($_GET['search'])) { if (isset($_GET['name'])) { if ($_GET['name'] == "ascending") { $searchResults = $searchObject->sortCategoryBySearch($connection, "ASC", "CategoryName", $_GET['keywords']); } else { if ($_GET['name'] == "descending") { $searchResults = $searchObject->sortCategoryBySearch($connection, "DESC", "CategoryName", $_GET['keywords']); } } } else { $searchResults = $searchObject->makeCategorySearch($connection, $_GET['keywords']); } } else { if (isset($_GET['name'])) { if ($_GET['name'] == "ascending") { $searchResults = $searchObject->sortCategory($connection, "CategoryName", "ASC"); } else { $searchResults = $searchObject->sortCategory($connection, "CategoryName", "DESC"); } } else { if ($_GET['summary'] == "ascending") { $searchResults = $searchObject->sortCategory($connection, "CategorySummary", "ASC"); } else { $searchResults = $searchObject->sortCategory($connection, "CategorySummary", "DESC"); } } } } else { if ($searchType == "product") { if (isset($_GET['keywords'])) { if (isset($_GET['name'])) { if ($_GET['name'] == "ascending") { $searchResults = $searchObject->sortProductBySearch($connection, "ASC", "ProductName", $_GET['keywords']); } else { if ($_GET['name'] == "descending") { $searchResults = $searchObject->sortProductBySearch($connection, "DESC", "ProductName", $_GET['keywords']); } } } else { if (isset($_GET['calories'])) { if ($_GET['calories'] == "ascending") { $searchResults = $searchObject->sortProductBySearch($connection, "ASC", "ProductCalories", $_GET['keywords']); } else { if ($_GET['calories'] == "descending") { $searchResults = $searchObject->sortProductBySearch($connection, "DESC", "ProductCalories", $_GET['keywords']); } } } else { if (isset($_GET['price'])) { if ($_GET['price'] == "ascending") { $searchResults = $searchObject->sortProductBySearch($connection, "ASC", "ProductPrice", $_GET['keywords']); } else { if ($_GET['price'] == "descending") { $searchResults = $searchObject->sortProductBySearch($connection, "DESC", "ProductPrice", $_GET['keywords']); } } } else { if (isset($_GET['description'])) { if ($_GET['description'] == "ascending") { $searchResults = $searchObject->sortProductBySearch($connection, "ASC", "ProductDescription", $_GET['keywords']); } else { if ($_GET['description'] == "descending") { $searchResults = $searchObject->sortProductBySearch($connection, "DESC", "ProductDescription", $_GET['keywords']); } } } else { $searchResults = $searchObject->makeProductSearch($connection, $_GET['keywords']); } } } } } else { if (isset($_GET['name'])) { if ($_GET['name'] == "ascending") { $searchResults = $searchObject->sortProduct($connection, "ProductName", "ASC"); } else { $searchResults = $searchObject->sortProduct($connection, "ProductName", "DESC"); } } else { if (isset($_GET['calories'])) { if ($_GET['calories'] == "ascending") { $searchResults = $searchObject->sortProduct($connection, "ProductCalories", "ASC"); } else { $searchResults = $searchObject->sortProduct($connection, "ProductCalories", "DESC"); } } else { if (isset($_GET['description'])) { if ($_GET['description'] == "ascending") { $searchResults = $searchObject->sortProduct($connection, "ProductDescription", "ASC"); } else { $searchResults = $searchObject->sortProduct($connection, "ProductDescription", "DESC"); } } else { if (isset($_GET['price'])) { if ($_GET['price'] == "ascending") { $searchResults = $searchObject->sortProduct($connection, "ProductPrice", "ASC"); } else { $searchResults = $searchObject->sortProduct($connection, "ProductPrice", "DESC"); } } } } } } } } } close_database_connection($connection); // store username into args array $argsArray = array('title' => $_GET['keywords'] . " search results", 'username' => $username, 'searchType' => $searchType, 'searchResults' => $searchResults, 'search' => $_GET['keywords']); // render (draw) template // ------------ $templateName = 'admin/adminSearch'; return $app['twig']->render($templateName . '.html.twig', $argsArray); }