Esempio n. 1
0
 public function test_delete_with_relations()
 {
     $note = $this->get_last_row();
     $is_draft = !$note->is_published;
     $note_id = $note->id;
     $note->delete_with_relations();
     // 件数
     // note
     $this->assertEquals(self::$note_count - 1, Model_Note::get_count());
     // note_album_image
     $note_album_images = \Note\Model_NoteAlbumImage::query()->where('note_id', $note_id)->get();
     $this->assertEmpty($note_album_images);
     // timeline
     if (is_enabled('timeline')) {
         if ($is_draft) {
             $this->assertEquals(self::$timeline_count, \Util_Orm::get_count_all('\\Timeline\\Model_Timeline'));
             $this->assertEquals(self::$timeline_cache_count, \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache'));
         } else {
             $this->assertEquals(self::$timeline_count - 1, \Util_Orm::get_count_all('\\Timeline\\Model_Timeline'));
             $this->assertEquals(self::$timeline_cache_count - 2, \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache'));
             $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('note', $note->id, \Config::get('timeline.types.note'));
             $this->assertEmpty($timelines);
         }
     }
 }