function test_getTrendingPromptrs() { $name = "mikes 5 top interview questions"; $topic_id = 5; $trending_index = 3; $test_promptr = new Promptr($name, $topic_id, $trending_index); $test_promptr->save(); $name2 = "mikes 50 top interview questions"; $trending_index2 = 4; $test_promptr2 = new Promptr($name2, $topic_id, $trending_index2); $test_promptr2->save(); $name3 = "mikes 500 top interview questions"; $trending_index3 = 5; $test_promptr3 = new Promptr($name3, $topic_id, $trending_index3); $test_promptr3->save(); $name4 = "mikes 5000 top interview questions"; $trending_index4 = 6; $test_promptr4 = new Promptr($name4, $topic_id, $trending_index4); $test_promptr4->save(); $name5 = "mikes 50000 top interview questions"; $trending_index5 = 7; $test_promptr5 = new Promptr($name5, $topic_id, $trending_index5); $test_promptr5->save(); $name6 = "mikes 500000 top interview questions"; $trending_index6 = 8; $test_promptr6 = new Promptr($name6, $topic_id, $trending_index6); $test_promptr6->save(); //Act $result = Promptr::getTrendingPromptrs(); //Assert $this->assertEquals([$test_promptr6, $test_promptr5, $test_promptr4, $test_promptr3, $test_promptr2], $result); }
$promptr = Promptr::find($id); $topic = Topic::find($promptr->getTopicId()); $new_question_text = $_POST['question']; $new_description = $_POST['description']; $new_question = new Question($new_question_text, $new_description); $new_question->save(); $promptr->addQuestion($new_question); return $app['twig']->render('promptr.html.twig', array('promptr' => $promptr, 'questions' => $promptr->getQuestions(), 'topic' => $topic)); }); // PROMPTRS.HTML.TWIG // ADD PROMPTR -- adds a prompter and displays promptrs within the topic $app->post("/promptrs", function () use($app) { $promptr_name = $_POST['promptr_name']; $topic_id = $_POST['topic_id']; $new_promptr = new Promptr($promptr_name, $topic_id); $new_promptr->save(); return $app['twig']->render('promptrs.html.twig', array('promptrs' => Promptr::getAll(), 'topic' => $topic_id, 'topic_picked' => true)); // flag for included template }); $app->get("/topic/{id}", function ($id) use($app) { $topic = Topic::find($id); $promptrs = $topic->getPromptrs(); $allT = Topic::getAll(); return $app['twig']->render("topic.html.twig", array('topic' => $topic, 'promptrs' => $promptrs, 'all_topics' => $allT)); }); // PROMPTR.HTML.TWIG //delete question from NEW PROMPTR route -- then displays promptr page $app->get("promptr/{id}", function ($id) use($app) { $promptr = Promptr::find($id); $questions = $promptr->getQuestions(); return $app['twig']->render("promptr.html.twig", array('promptr' => $promptr, 'questions' => $questions));
function test_getPromptrs() { $name = "Writing"; $test_topic = new Topic($name); $test_topic->save(); $name2 = "Interview"; $test_topic2 = new Topic($name2); $test_topic2->save(); $promptr_name = "mikes 5 tips"; $topic_id = $test_topic->getId(); $test_promptr = new Promptr($promptr_name, $topic_id); $test_promptr->save(); $promptr_name2 = "ians 5 tips"; $topic_id = $test_topic->getId(); $test_promptr2 = new Promptr($promptr_name2, $topic_id); $test_promptr2->save(); $result = $test_topic->getPromptrs(); $this->assertEquals([$test_promptr, $test_promptr2], $result); }