Ci: PHPUnit: Modify unit tests to reflect real expectations of resource deletions

pull/5142/head
Yannick Warnier 2 years ago
parent f9fb2081db
commit 1a2bede962
  1. 3
      tests/CourseBundle/Repository/CForumRepositoryTest.php
  2. 3
      tests/CourseBundle/Repository/CGlossaryRepositoryTest.php
  3. 4
      tests/CourseBundle/Repository/CNotebookRepositoryTest.php
  4. 16
      tests/CourseBundle/Repository/CSurveyRepositoryTest.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([]));
}

@ -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([]));
}
}

@ -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([]));
}
}

@ -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([]));
}
}

Loading…
Cancel
Save