public function testDeleteRelatedMetaWhenRemovesAUser() { $user = Factory::create('User', ['id' => 1]); Factory::times(2)->create('PostMeta', ['meta_key' => 'pal_user_id', 'meta_value' => 1]); $metaBeforeDelete = $user->meta; $user->delete(); $metaAfterDelete = PostMeta::where('meta_key', '=', 'pal_user_id')->where('meta_value', '=', $user->id)->get(); assertThat($metaBeforeDelete, is(nonEmptyTraversable())); assertThat($metaAfterDelete, is(emptyTraversable())); }
public function testDeleteRelatedMetaModelsWhenRemovesAGallery() { $gallery = Factory::create('Gallery'); Factory::create('PostMeta', ['post_id' => 1]); $metaBeforeDelete = $gallery->meta; $gallery->delete(); $metaAfterDelete = PostMeta::where('post_id', '=', 1)->get(); assertThat($metaBeforeDelete, is(nonEmptyTraversable())); assertThat($metaAfterDelete, is(emptyTraversable())); }