diff --git a/tests/CourseBundle/Repository/CForumRepositoryTest.php b/tests/CourseBundle/Repository/CForumRepositoryTest.php index eab8760f9e..a1de0e0f04 100644 --- a/tests/CourseBundle/Repository/CForumRepositoryTest.php +++ b/tests/CourseBundle/Repository/CForumRepositoryTest.php @@ -62,7 +62,8 @@ class CForumRepositoryTest extends AbstractApiTest $courseRepo->delete($course); - $this->assertSame(0, $forumRepo->count([])); + // A forum can be global, so don't delete it upon course deletion + $this->assertSame(1, $forumRepo->count([])); $this->assertSame(0, $courseRepo->count([])); } diff --git a/tests/CourseBundle/Repository/CGlossaryRepositoryTest.php b/tests/CourseBundle/Repository/CGlossaryRepositoryTest.php index 09f56b5333..14d7e7c4d7 100644 --- a/tests/CourseBundle/Repository/CGlossaryRepositoryTest.php +++ b/tests/CourseBundle/Repository/CGlossaryRepositoryTest.php @@ -54,7 +54,8 @@ class CGlossaryRepositoryTest extends AbstractApiTest $courseRepo->delete($course); + // A glossary is a global resource, so don't cascade-delete it + $this->assertSame(1, $glossaryRepo->count([])); $this->assertSame(0, $courseRepo->count([])); - $this->assertSame(0, $glossaryRepo->count([])); } } diff --git a/tests/CourseBundle/Repository/CNotebookRepositoryTest.php b/tests/CourseBundle/Repository/CNotebookRepositoryTest.php index 52ee845707..60e7b112c5 100644 --- a/tests/CourseBundle/Repository/CNotebookRepositoryTest.php +++ b/tests/CourseBundle/Repository/CNotebookRepositoryTest.php @@ -42,7 +42,9 @@ class CNotebookRepositoryTest extends AbstractApiTest $courseRepo->delete($course); + // Notebook resources belong to the user before anything else, + // and should not be cascade-deleted with the course + $this->assertSame(1, $notebookRepo->count([])); $this->assertSame(0, $courseRepo->count([])); - $this->assertSame(0, $notebookRepo->count([])); } } diff --git a/tests/CourseBundle/Repository/CSurveyRepositoryTest.php b/tests/CourseBundle/Repository/CSurveyRepositoryTest.php index f4a5db386a..b8ebe738d5 100644 --- a/tests/CourseBundle/Repository/CSurveyRepositoryTest.php +++ b/tests/CourseBundle/Repository/CSurveyRepositoryTest.php @@ -80,7 +80,10 @@ class CSurveyRepositoryTest extends AbstractApiTest $this->assertCount(1, $qb->getQuery()->getResult()); $courseRepo->delete($course); - $this->assertSame(0, $surveyRepo->count([])); + + // A survey is a global resource that should not be cascade-deleted + // by the course + $this->assertSame(1, $surveyRepo->count([])); $this->assertSame(0, $courseRepo->count([])); } @@ -192,11 +195,12 @@ class CSurveyRepositoryTest extends AbstractApiTest $course = $this->getCourse($course->getId()); $courseRepo->delete($course); - $this->assertSame(0, $courseRepo->count([])); - $this->assertSame(0, $surveyRepo->count([])); - $this->assertSame(0, $surveyQuestionRepo->count([])); - $this->assertSame(0, $surveyAnswerRepo->count([])); + // Surveys are global and should not be cascade-deleted by the course $this->assertSame(0, $surveyInvitationRepo->count([])); - $this->assertSame(0, $surveyOptionRepo->count([])); + $this->assertSame(1, $surveyQuestionRepo->count([])); + $this->assertSame(1, $surveyAnswerRepo->count([])); + $this->assertSame(1, $surveyOptionRepo->count([])); + $this->assertSame(1, $surveyRepo->count([])); + $this->assertSame(0, $courseRepo->count([])); } }