Exemple #1
0
 static function find($search_id)
 {
     $found_inventory = null;
     $rocks = Rock::getAll();
     foreach ($rocks as $rock) {
         $rock_id = $rock->getId();
         if ($rock_id == $search_id) {
             $found_rock = $task;
         }
     }
     return $found_rock;
 }
Exemple #2
0
 function test_deleteAll()
 {
     //Arrange
     $description = "Granite";
     $description2 = "Crystal";
     $test_Rock = new Rock($description);
     $test_Rock->save();
     $test_Rock2 = new Rock($description2);
     $test_Rock2->save();
     //Act
     Rock::deleteAll();
     //Asser
     $result = Rock::getAll();
     $this->assertEquals([], $result);
 }
Exemple #3
0
$password = '';
$DB = new PDO($server, $username, $password);
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig');
});
$app->get("/rocks", function () use($app) {
    return $app['twig']->render('rocks.html.twig', array('rocks' => Rock::getAll()));
});
$app->get("/categories", function () use($app) {
    return $app['twig']->render('categories.html.twig', array('categories' => Category::getAll()));
});
$app->post("/rocks", function () use($app) {
    $rock = new Rock($_POST['description']);
    $rock->save();
    return $app['twig']->render('rocks.html.twig', array('rocks' => Rock::getAll()));
});
$app->post("/delete_rocks", function () use($app) {
    Rock::deleteAll();
    return $app['twig']->render('index.html.twig');
});
$app->post("/categories", function () use($app) {
    $category = new Category($_POST['name']);
    $category->save();
    return $app['twig']->render('categories.html.twig', array('categories' => Category::getAll()));
});
$app->post("/delete_categories", function () use($app) {
    Category::deleteAll();
    return $app['twig']->render('index.html.twig');
});
return $app;