function testIfObjectRetunsListOfRecipes()
 {
     $recipe = new Recipe(1);
     $user = new User(1);
     $starredRecipe = new StarredRecipe($user->id(), $recipe->id());
     $this->assertTrue(!empty($starredRecipe->recipes()));
 }
Пример #2
0
 function starredRecipeList($userId, $recipeId, $page = 1, $toggle = false)
 {
     $recipe = new Recipe($recipeId);
     $user = new User($userId);
     $starredRecipe = new StarredRecipe($userId);
     $isStarred = false;
     foreach ($starredRecipe->recipes() as $recipe1) {
         if ($recipe->id() == $recipe1->id()) {
             //echo $recipe->id() . " == ". $recipe1->id();
             $isStarred = true;
         }
     }
     if ($toggle) {
         if ($isStarred) {
             $starredRecipe->unstarRecipe($userId, $recipeId);
         } else {
             $starredRecipe->starRecipe($userId, $recipeId);
         }
     }
     return $starredRecipe->recipes();
 }
Пример #3
0
$title = "BBC Test | Recipe";
$metaTitle = "Recipe";
$metaKeywords = "Recipe";
$metaDescription = "Recipe";
if (!empty($_GET['id'])) {
    $recipeId = $_GET['id'];
} else {
    $recipeId = 0;
}
$recipe = new Recipe($recipeId);
include_once 'parts/htmlHead.php';
$starredRecipe = new StarredRecipe($user->id());
$star = "fa-star-o";
if (sizeof($starredRecipe->recipes()) > 0 && $starredRecipe->recipes()[0]->id() != 0) {
    foreach ($starredRecipe->recipes() as $recipe1) {
        if ($recipe->id() == $recipe1->id()) {
            $star = "fa-star";
        }
    }
}
?>
<body>
	<main id="main" data-user="******" data-recipe="<?php 
echo $recipe->id();
?>
"></main>
    <!-- Navigation -->
    <a id="menu-toggle" href="#" class="btn btn-dark btn-lg toggle"><i class="fa fa-bars"></i></a>