Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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');
 }