Пример #1
0
 public function testSaveWithException()
 {
     $faker = $this->getFaker();
     $News = new News();
     $News->setTitle('news-10')->setComment($faker->text())->setUrl($faker->url)->setCreator($this->Member)->setSelect(null)->setLinkMethod(1);
     $result = $this->app['eccube.repository.news']->save($News);
     $this->assertFalse($result);
 }
Пример #2
0
 /**
  * News を削除する.
  *
  * @param  \Eccube\Entity\News $News
  * @return boolean 成功した場合 true
  */
 public function delete(\Eccube\Entity\News $News)
 {
     $em = $this->getEntityManager();
     $em->getConnection()->beginTransaction();
     try {
         $rank = $News->getRank();
         $em->createQueryBuilder()->update('Eccube\\Entity\\News', 'n')->set('n.rank', 'n.rank - 1')->where('n.rank > :rank')->setParameter('rank', $rank)->getQuery()->execute();
         $News->setDelFlg(1)->setRank(0);
         $em->persist($News);
         $em->flush();
         $em->getConnection()->commit();
     } catch (\Exception $e) {
         $em->getConnection()->rollback();
         return false;
     }
     return true;
 }