function test_find() { //Arrange $description = "Granite"; $description2 = "Crystal"; $test_Rock = new Rock($description); $test_Rock->save(); $test_Rock2 = new Rock($description2); $test_Rock2->save(); //Act $id = $test_Rock->getId(); $result = Rock::find($id); //Assert $this->assertEquals($test_Rock, $result); }
$username = '******'; $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'); });