getEntityManager(); $notebookRepo = self::getContainer()->get(CNotebookRepository::class); $courseRepo = self::getContainer()->get(CourseRepository::class); $course = $this->createCourse('new'); $teacher = $this->createUser('teacher'); $notebook = (new CNotebook()) ->setTitle('item') ->setDescription('desc') ->setParent($course) ->setCreator($teacher) ; $this->assertHasNoEntityViolations($notebook); $em->persist($notebook); $em->flush(); $this->assertSame('item', (string) $notebook); $this->assertSame($notebook->getResourceIdentifier(), $notebook->getIid()); $this->assertSame(1, $notebookRepo->count([])); $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([])); } }