public function testAll() { $this->model = new ArticleModel(); $array = ['user' => '1', 'title' => 'plop', 'text' => 'test', 'image' => 'http://lol.com/lol.png', 'category' => '1']; $state = $this->model->insertNews($array); $this->assertEquals(true, $state); $state = $this->model->getOneNewsByName('plop'); $this->assertNotEmpty($state); $state = $this->model->updateNewsByName('plop', date('Y-m-d G:i:s'), 'Je sais toujours pas'); $this->assertEquals(true, $state); $state = $this->model->deleteNewsByName('plop'); $this->assertEquals(true, $state); }
public function addPOST() { if (!Authentication::getInstance()->isAuthenticated()) { throw new NotAuthenticatedException(); } $form = FormHelper::generate('article', '/article/add'); $result = $form->validate(['title' => 'Titre de l\'ActualitΓ©', 'image' => 'URL Image', 'text' => 'Contenu']); $result['user'] = Authentication::getInstance()->getUserId(); // HARDCODE IS BAD $result['category'] = 1; $this->articleModel->insertNews($result); $this->getView()->redirect('/article'); }