Beispiel #1
0
 /**
  * Tests removing object from the middle of sorted 1:M relation (Blog:Posts)
  *
  * @test
  */
 public function removeMiddlePostFromBlog()
 {
     $countPostsOriginal = $this->getDatabaseConnection()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post', 'deleted=0');
     $posts = clone $this->blog->getPosts();
     $counter = 1;
     foreach ($posts as $post) {
         if ($counter == 5) {
             $this->blog->removePost($post);
         }
         $counter++;
     }
     $this->updateAndPersistBlog();
     $countPosts = $this->getDatabaseConnection()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post', 'deleted=0');
     $this->assertSame($countPostsOriginal - 1, $countPosts);
     $post = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'blog =' . $this->blog->getUid(), '', 'sorting DESC');
     $this->assertSame('Post10', $post['title']);
     $this->assertSame('10', $post['sorting']);
 }