diff --git a/src/CoreBundle/Entity/ResourceNode.php b/src/CoreBundle/Entity/ResourceNode.php index 4b2f7b8326..1640af17d6 100644 --- a/src/CoreBundle/Entity/ResourceNode.php +++ b/src/CoreBundle/Entity/ResourceNode.php @@ -18,7 +18,6 @@ use Chamilo\CourseBundle\Entity\CShortcut; use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use InvalidArgumentException; @@ -465,21 +464,6 @@ class ResourceNode return $this; } - /** - * @return Collection|ResourceLink[] - */ - public function hasSession(Session $session = null) - { - $links = $this->getResourceLinks(); - $criteria = Criteria::create(); - - $criteria->andWhere( - Criteria::expr()->eq('session', $session) - ); - - return $links->matching($criteria); - } - public function hasResourceFile(): bool { return null !== $this->resourceFile; diff --git a/tests/ChamiloTestTrait.php b/tests/ChamiloTestTrait.php index e4cb10d99a..598f3f90ca 100644 --- a/tests/ChamiloTestTrait.php +++ b/tests/ChamiloTestTrait.php @@ -6,6 +6,7 @@ use Chamilo\CoreBundle\Entity\AccessUrl; use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Session; use Chamilo\CoreBundle\Entity\User; +use Chamilo\CoreBundle\Entity\Usergroup; use Chamilo\CoreBundle\Repository\Node\AccessUrlRepository; use Chamilo\CoreBundle\Repository\Node\CourseRepository; use Chamilo\CoreBundle\Repository\Node\UserRepository; @@ -97,6 +98,23 @@ trait ChamiloTestTrait return $group; } + public function createUserGroup(string $title): ?Usergroup + { + $em = $this->getEntityManager(); + $creator = $this->createUser('usergroup_creator'); + + $group = (new Usergroup()) + ->setName($title) + ->setDescription('desc') + ->setCreator($creator) + ->addAccessUrl($this->getAccessUrl()) + ; + $em->persist($group); + $em->flush(); + + return $group; + } + /** * Finds a user registered in the test DB, added by the DataFixtures classes. */ diff --git a/tests/CoreBundle/Repository/Node/CourseRepositoryTest.php b/tests/CoreBundle/Repository/Node/CourseRepositoryTest.php index 41e8c6f7cd..c57ba705aa 100644 --- a/tests/CoreBundle/Repository/Node/CourseRepositoryTest.php +++ b/tests/CoreBundle/Repository/Node/CourseRepositoryTest.php @@ -84,8 +84,8 @@ class CourseRepositoryTest extends AbstractApiTest ; $courseRepo->create($course); - /** @var Course $course */ - $course = $courseRepo->find($course->getId()); + $course = $this->getCourse($course->getId()); + $this->assertSame('test julio', $course->getName()); $this->assertSame('test julio (TESTJULIO)', $course->getTitleAndCode()); $this->assertSame('TESTJULIO', $course->getCode()); diff --git a/tests/CoreBundle/Repository/Node/UsergroupRepositoryTest.php b/tests/CoreBundle/Repository/Node/UsergroupRepositoryTest.php index dd26c44340..02b129561a 100644 --- a/tests/CoreBundle/Repository/Node/UsergroupRepositoryTest.php +++ b/tests/CoreBundle/Repository/Node/UsergroupRepositoryTest.php @@ -125,6 +125,7 @@ class UsergroupRepositoryTest extends KernelTestCase $em->persist($group); $em->flush(); + $this->assertNotNull($userGroupRelCourse->getId()); $this->assertSame(1, $group->getCourses()->count()); $this->assertSame(1, $group->getQuestions()->count()); $this->assertSame(1, $group->getSessions()->count()); diff --git a/tests/CoreBundle/Repository/ResourceNodeRepositoryTest.php b/tests/CoreBundle/Repository/ResourceNodeRepositoryTest.php index 9f31d511f2..fee4f9b298 100644 --- a/tests/CoreBundle/Repository/ResourceNodeRepositoryTest.php +++ b/tests/CoreBundle/Repository/ResourceNodeRepositoryTest.php @@ -6,12 +6,16 @@ declare(strict_types=1); namespace Chamilo\Tests\CoreBundle\Repository; +use Chamilo\CoreBundle\Entity\ResourceComment; use Chamilo\CoreBundle\Entity\ResourceFile; +use Chamilo\CoreBundle\Entity\ResourceLink; use Chamilo\CoreBundle\Entity\ResourceNode; use Chamilo\CoreBundle\Entity\ResourceType; use Chamilo\CoreBundle\Repository\ResourceNodeRepository; use Chamilo\Tests\AbstractApiTest; use Chamilo\Tests\ChamiloTestTrait; +use DateTime; +use Symfony\Component\Routing\RouterInterface; class ResourceNodeRepositoryTest extends AbstractApiTest { @@ -19,8 +23,6 @@ class ResourceNodeRepositoryTest extends AbstractApiTest public function testCreate(): void { - self::bootKernel(); - $em = $this->getEntityManager(); $repo = self::getContainer()->get(ResourceNodeRepository::class); @@ -30,8 +32,54 @@ class ResourceNodeRepositoryTest extends AbstractApiTest $defaultCount = $repo->count([]); $type = $repoType->findOneBy(['name' => 'illustrations']); + $resourceNode = (new ResourceNode()) + ->setContent('test') + ->setTitle('test') + ->setSlug('test') + ->setResourceType($type) + ->setCreator($user) + ->setPublic(true) + ->setParent($user->getResourceNode()) + ; + $this->assertHasNoEntityViolations($resourceNode); + $em->persist($resourceNode); + $em->flush(); - $node = (new ResourceNode()) + $this->assertNotNull((string) $resourceNode); + $this->assertSame(2, $resourceNode->getLevel()); + $path = $user->getResourceNode()->getSlug().'-'.$user->getResourceNode()->getId().'/'.$resourceNode->getSlug().'-'.$resourceNode->getId().'/'; + $this->assertSame($path, $resourceNode->getPathForDisplay()); + $array = [ + $user->getResourceNode()->getId() => $user->getResourceNode()->getSlug(), + $resourceNode->getId() => $resourceNode->getSlug(), + ]; + + $this->assertSame($array, $resourceNode->getPathForDisplayToArray()); + + $path = $user->getResourceNode()->getSlug().'/'.$resourceNode->getSlug(); + $this->assertSame($path, $resourceNode->getPathForDisplayRemoveBase('')); + + $this->assertSame('test', $resourceNode->getSlug()); + $this->assertFalse($resourceNode->isResourceFileAnImage()); + $this->assertFalse($resourceNode->isResourceFileAVideo()); + $this->assertNotEmpty(1, $resourceNode->getIcon()); + + $router = $this->getContainer()->get(RouterInterface::class); + $this->assertSame('', $resourceNode->getThumbnail($router)); + + $this->assertSame($defaultCount + 1, $repo->count([])); + } + + public function testCreateWithComment(): void + { + $em = $this->getEntityManager(); + $repo = self::getContainer()->get(ResourceNodeRepository::class); + + $repoType = $em->getRepository(ResourceType::class); + $user = $this->createUser('julio'); + + $type = $repoType->findOneBy(['name' => 'illustrations']); + $resourceNode = (new ResourceNode()) ->setContent('test') ->setTitle('test') ->setSlug('test') @@ -39,12 +87,84 @@ class ResourceNodeRepositoryTest extends AbstractApiTest ->setCreator($user) ->setParent($user->getResourceNode()) ; - $this->assertHasNoEntityViolations($node); - $em->persist($node); + $em->persist($resourceNode); + + $comment = (new ResourceComment()) + ->setContent('content') + ->setAuthor($user) + ->setParent(null) + ->setCreatedAt(new DateTime()) + ->setResourceNode($resourceNode) + ->setUpdatedAt(new DateTime()) + ; + $em->persist($comment); + $resourceNode->addComment($comment); $em->flush(); - $this->assertSame($defaultCount + 1, $repo->count([])); + $this->assertNotNull($comment->getResourceNode()); + $this->assertSame(1, $resourceNode->getComments()->count()); + } + + public function testCreateWithResourceLink(): void + { + $em = $this->getEntityManager(); + + $repo = self::getContainer()->get(ResourceNodeRepository::class); + $repoType = $em->getRepository(ResourceType::class); + + $user = $this->createUser('julio'); + $student = $this->createUser('student'); + $course = $this->createCourse('course'); + $session = $this->createSession('session'); + $group = $this->createGroup('group', $course); + $userGroup = $this->createUserGroup('group'); + + $type = $repoType->findOneBy(['name' => 'illustrations']); + $resourceNode = (new ResourceNode()) + ->setContent('test') + ->setTitle('test') + ->setSlug('test') + ->setResourceType($type) + ->setCreator($user) + ->setParent($user->getResourceNode()) + ; + $em->persist($resourceNode); + + $link = (new ResourceLink()) + ->setVisibility(ResourceLink::VISIBILITY_PUBLISHED) + ->setResourceNode($resourceNode) + ->setUser($student) + ->setCourse($course) + ->setSession($session) + ->setGroup($group) + ->setUserGroup($userGroup) + ->setCreatedAt(new DateTime()) + ->setUpdatedAt(new DateTime()) + ->setStartVisibilityAt(new DateTime()) + ->setEndVisibilityAt(new DateTime()) + ; + $em->persist($link); + $em->flush(); + $em->clear(); + + /** @var ResourceNode $resourceNode */ + $resourceNode = $repo->find($resourceNode->getId()); + + $this->assertSame(1, $resourceNode->getResourceLinks()->count()); + /** @var ResourceLink $link */ + $link = $resourceNode->getResourceLinks()->first(); + + $this->assertNotNull($link->getStartVisibilityAt()); + $this->assertNotNull($link->getEndVisibilityAt()); + $this->assertTrue($link->hasSession()); + $this->assertTrue($link->hasCourse()); + $this->assertTrue($link->hasUser()); + $this->assertTrue($link->hasGroup()); + + $this->assertTrue($link->isPublished()); + $this->assertFalse($link->isPending()); + $this->assertFalse($link->isDraft()); } public function testGetResourceNodeFileContent(): void @@ -91,6 +211,7 @@ class ResourceNodeRepositoryTest extends AbstractApiTest $this->assertSame('desc', $resourceFile->getDescription()); $this->assertNotEmpty($resourceFile->getWidth()); $this->assertNotEmpty($resourceFile->getHeight()); + $this->assertIsArray($resourceFile->getMetadata()); $content = $repo->getResourceNodeFileContent($node); $this->assertNotEmpty($content); diff --git a/tests/CoreBundle/Repository/SessionRepositoryTest.php b/tests/CoreBundle/Repository/SessionRepositoryTest.php index 5841406523..a38cea7e8c 100644 --- a/tests/CoreBundle/Repository/SessionRepositoryTest.php +++ b/tests/CoreBundle/Repository/SessionRepositoryTest.php @@ -366,7 +366,7 @@ class SessionRepositoryTest extends AbstractApiTest $this->assertSame(1, $session->getCourses()->count()); // 3. Add student to session - course. - $course = $courseRepo->find($course->getId()); + $course = $this->getCourse($course->getId()); /** @var User $user */ $user = $userRepo->find($user->getId()); @@ -425,8 +425,6 @@ class SessionRepositoryTest extends AbstractApiTest public function testGeneralCoachesInSession(): void { - self::bootKernel(); - $sessionRepo = self::getContainer()->get(SessionRepository::class); $session = $this->createSession('test for general coaches'); @@ -443,8 +441,6 @@ class SessionRepositoryTest extends AbstractApiTest public function testAdminInSession(): void { - self::bootKernel(); - $sessionRepo = self::getContainer()->get(SessionRepository::class); $session = $this->createSession('test for session admin'); diff --git a/tests/CoreBundle/Repository/SysAnnouncementRepositoryTest.php b/tests/CoreBundle/Repository/SysAnnouncementRepositoryTest.php index 729f87ba43..33a96de8ba 100644 --- a/tests/CoreBundle/Repository/SysAnnouncementRepositoryTest.php +++ b/tests/CoreBundle/Repository/SysAnnouncementRepositoryTest.php @@ -38,12 +38,15 @@ class SysAnnouncementRepositoryTest extends WebTestCase $this->assertSame(1, $count); $em = $this->getEntityManager(); + $sysAnnouncement = (new SysAnnouncement()) ->setTitle('Welcome to Chamilo!') ->setContent('content') + ->setLang('lang') ->setUrl($this->getAccessUrl()) ->setDateStart(new DateTime()) ->setDateEnd(new DateTime('now +30 days')) + ->setRoles(['ROLE_ANOTHER']) ->addRole('ROLE_ANONYMOUS') ->addRole('ROLE_USER') // connected users ; @@ -52,6 +55,11 @@ class SysAnnouncementRepositoryTest extends WebTestCase $repo->update($sysAnnouncement); + $this->assertNotNull($sysAnnouncement->getDateStart()); + $this->assertNotNull($sysAnnouncement->getDateEnd()); + $this->assertNotNull($sysAnnouncement->getLang()); + $this->assertCount(3, $sysAnnouncement->getRoles()); + $this->assertTrue($sysAnnouncement->isVisible()); $this->assertSame(2, $repo->count([])); $repo->delete($sysAnnouncement->getId()); @@ -73,7 +81,7 @@ class SysAnnouncementRepositoryTest extends WebTestCase $repo = self::getContainer()->get(SysAnnouncementRepository::class); $user = $this->getUser('admin'); $items = $repo->getAnnouncements($user, $this->getAccessUrl(), ''); - $this->assertSame(1, \count($items)); + $this->assertCount(1, $items); $career = (new Career()) ->setName('Doctor') @@ -95,6 +103,7 @@ class SysAnnouncementRepositoryTest extends WebTestCase ->setDateStart(new DateTime()) ->setDateEnd(new DateTime('now +30 days')) ->setCareer($career) + ->setPromotion($promotion) ->addRole('ROLE_ANONYMOUS') ->addRole('ROLE_USER') // connected users ; diff --git a/tests/CoreBundle/Repository/TagRepositoryTest.php b/tests/CoreBundle/Repository/TagRepositoryTest.php index 7caf8bf0de..b0c64a03ea 100644 --- a/tests/CoreBundle/Repository/TagRepositoryTest.php +++ b/tests/CoreBundle/Repository/TagRepositoryTest.php @@ -44,6 +44,9 @@ class TagRepositoryTest extends AbstractApiTest $em->persist($tag); $em->flush(); + $this->assertSame('php', $tag->getTag()); + + $this->assertSame(0, $tag->getUserRelTags()->count()); $this->assertSame(1, $repo->count([])); $tags = $repo->findTagsByField('php', $extraField); @@ -78,6 +81,9 @@ class TagRepositoryTest extends AbstractApiTest ->setTag($tag) ; $em->persist($userRelTag); + + $tag->getUserRelTags()->add($userRelTag); + $em->flush(); $em->clear(); diff --git a/tests/CoreBundle/Repository/TrackExerciseRepositoryTest.php b/tests/CoreBundle/Repository/TrackExerciseRepositoryTest.php index d054957519..406286595e 100644 --- a/tests/CoreBundle/Repository/TrackExerciseRepositoryTest.php +++ b/tests/CoreBundle/Repository/TrackExerciseRepositoryTest.php @@ -215,9 +215,9 @@ class TrackExerciseRepositoryTest extends AbstractApiTest $this->assertSame(1, $trackExercise->getAttempts()->count()); $this->assertInstanceOf(TrackEAttempt::class, $trackExercise->getAttemptByQuestionId(1)); + $this->assertNull($trackExercise->getAttemptByQuestionId(99)); $file = $this->getUploadedFile(); - $em = $this->getEntityManager(); // Create asset. diff --git a/tests/CoreBundle/Tool/ToolChainTest.php b/tests/CoreBundle/Tool/ToolChainTest.php index 1069b92c07..f4c8493660 100644 --- a/tests/CoreBundle/Tool/ToolChainTest.php +++ b/tests/CoreBundle/Tool/ToolChainTest.php @@ -168,6 +168,7 @@ class ToolChainTest extends AbstractApiTest ; $this->assertHasNoEntityViolations($resourceType); $em->persist($resourceType); + $collection = new ArrayCollection(); $collection->add($resourceType); @@ -178,5 +179,7 @@ class ToolChainTest extends AbstractApiTest $this->assertHasNoEntityViolations($tool); $em->persist($tool); $em->flush(); + + $this->assertNotNull($resourceType->getId()); } } diff --git a/tests/CourseBundle/Repository/CCalendarEventAttachmentRepositoryTest.php b/tests/CourseBundle/Repository/CCalendarEventAttachmentRepositoryTest.php index a44d261d23..c987ab9c2c 100644 --- a/tests/CourseBundle/Repository/CCalendarEventAttachmentRepositoryTest.php +++ b/tests/CourseBundle/Repository/CCalendarEventAttachmentRepositoryTest.php @@ -20,7 +20,6 @@ class CCalendarEventAttachmentRepositoryTest extends AbstractApiTest public function testCreateEvent(): void { - self::bootKernel(); $user = $this->createUser('test'); $course = $this->createCourse('new'); @@ -55,6 +54,8 @@ class CCalendarEventAttachmentRepositoryTest extends AbstractApiTest ->addCourseLink($course) ; + $event->addAttachment($attachment); + $this->assertHasNoEntityViolations($attachment); $repoAttachment->create($attachment); diff --git a/tests/CourseBundle/Repository/CCourseDescriptionRepositoryTest.php b/tests/CourseBundle/Repository/CCourseDescriptionRepositoryTest.php index 852e0cc1db..20b82694ae 100644 --- a/tests/CourseBundle/Repository/CCourseDescriptionRepositoryTest.php +++ b/tests/CourseBundle/Repository/CCourseDescriptionRepositoryTest.php @@ -17,8 +17,6 @@ class CCourseDescriptionRepositoryTest extends AbstractApiTest public function testCreate(): void { - self::bootKernel(); - $em = $this->getEntityManager(); $repo = self::getContainer()->get(CCourseDescriptionRepository::class); @@ -38,13 +36,13 @@ class CCourseDescriptionRepositoryTest extends AbstractApiTest $em->flush(); $this->assertSame('title', (string) $item); + $this->assertNotNull($item->getProgress()); + $this->assertSame($item->getIid(), $item->getResourceIdentifier()); $this->assertSame(1, $repo->count([])); } public function testGetDescriptions(): void { - self::bootKernel(); - $repo = self::getContainer()->get(CCourseDescriptionRepository::class); $em = $this->getEntityManager(); diff --git a/tests/CourseBundle/Repository/CDocumentRepositoryTest.php b/tests/CourseBundle/Repository/CDocumentRepositoryTest.php index 297d06f538..0cfaf8fea3 100644 --- a/tests/CourseBundle/Repository/CDocumentRepositoryTest.php +++ b/tests/CourseBundle/Repository/CDocumentRepositoryTest.php @@ -463,7 +463,7 @@ class CDocumentRepositoryTest extends AbstractApiTest // Update course visibility to REGISTERED $courseRepo = self::getContainer()->get(CourseRepository::class); - $course = $courseRepo->find($courseId); + $course = $this->getCourse($courseId); $course->setVisibility(Course::REGISTERED); $courseRepo->update($course); @@ -490,7 +490,7 @@ class CDocumentRepositoryTest extends AbstractApiTest // Update course visibility to CLOSED $courseRepo = self::getContainer()->get(CourseRepository::class); - $course = $courseRepo->find($courseId); + $course = $this->getCourse($courseId); $course->setVisibility(Course::CLOSED); $courseRepo->update($course); @@ -508,7 +508,7 @@ class CDocumentRepositoryTest extends AbstractApiTest // Update course visibility to HIDDEN $courseRepo = self::getContainer()->get(CourseRepository::class); - $course = $courseRepo->find($courseId); + $course = $this->getCourse($courseId); $course->setVisibility(Course::HIDDEN); $courseRepo->update($course); diff --git a/tests/CourseBundle/Repository/CGroupRepositoryTest.php b/tests/CourseBundle/Repository/CGroupRepositoryTest.php index 72aaf9ae50..7cb46479fb 100644 --- a/tests/CourseBundle/Repository/CGroupRepositoryTest.php +++ b/tests/CourseBundle/Repository/CGroupRepositoryTest.php @@ -50,7 +50,11 @@ class CGroupRepositoryTest extends AbstractApiTest $em->persist($item); $em->flush(); + $this->assertTrue($item->getSelfRegistrationAllowed()); + $this->assertTrue($item->getSelfUnregistrationAllowed()); + $this->assertSame(1, $repo->count([])); + $this->assertNotNull($repo->findOneByTitle('Group')); $repo->delete($item); @@ -118,6 +122,9 @@ class CGroupRepositoryTest extends AbstractApiTest $em->persist($group); $em->flush(); + $this->assertFalse($group->hasTutors()); + $this->assertFalse($group->hasMembers()); + $groupRelUser = (new CGroupRelUser()) ->setStatus(1) ->setUser($student) @@ -140,6 +147,7 @@ class CGroupRepositoryTest extends AbstractApiTest /** @var CGroup $group */ $group = $groupRepo->find($group->getIid()); + $this->assertSame($group->getResourceIdentifier(), $group->getIid()); $this->assertSame(1, $group->getMembers()->count()); $this->assertSame(1, $group->getTutors()->count()); @@ -153,7 +161,7 @@ class CGroupRepositoryTest extends AbstractApiTest $this->assertSame(1, $groupRepo->count([])); $this->assertNotNull($groupRepo->findOneByTitle('Group')); - $course = $courseRepo->find($course->getId()); + $course = $this->getCourse($course->getId()); $courseRepo->delete($course); $this->assertSame(0, $groupRepo->count([])); diff --git a/tests/CourseBundle/Repository/CStudentPublicationRepositoryTest.php b/tests/CourseBundle/Repository/CStudentPublicationRepositoryTest.php index ee2edda455..7d64166310 100644 --- a/tests/CourseBundle/Repository/CStudentPublicationRepositoryTest.php +++ b/tests/CourseBundle/Repository/CStudentPublicationRepositoryTest.php @@ -6,7 +6,9 @@ declare(strict_types=1); namespace Chamilo\Tests\CourseBundle\Repository; +use Chamilo\CoreBundle\Repository\Node\CourseRepository; use Chamilo\CourseBundle\Entity\CStudentPublication; +use Chamilo\CourseBundle\Entity\CStudentPublicationRelUser; use Chamilo\CourseBundle\Repository\CStudentPublicationRepository; use Chamilo\Tests\AbstractApiTest; use Chamilo\Tests\ChamiloTestTrait; @@ -54,15 +56,19 @@ class CStudentPublicationRepositoryTest extends AbstractApiTest $this->assertSame(1, $repo->count([])); } - public function testCreateWithAssignment(): void + public function testCreateWithPublicationRelUser(): void { $em = $this->getEntityManager(); + $repo = self::getContainer()->get(CStudentPublicationRepository::class); + $courseRepo = self::getContainer()->get(CourseRepository::class); + $publicationRelUserRepo = $em->getRepository(CStudentPublicationRelUser::class); $course = $this->createCourse('new'); $teacher = $this->createUser('teacher'); + $student = $this->createUser('student'); - $item = (new CStudentPublication()) + $publication = (new CStudentPublication()) ->setTitle('publi') ->setDescription('desc') ->setParent($course) @@ -70,10 +76,26 @@ class CStudentPublicationRepositoryTest extends AbstractApiTest ->setWeight(100) ->setCreator($teacher) ; - $em->persist($item); + $em->persist($publication); + + $pubRelUser = (new CStudentPublicationRelUser()) + ->setUser($student) + ->setPublication($publication) + ; + $em->persist($pubRelUser); $em->flush(); $this->assertSame(1, $repo->count([])); + $this->assertSame(1, $courseRepo->count([])); + $this->assertSame(1, $publicationRelUserRepo->count([])); + + $course = $this->getCourse($course->getId()); + + $courseRepo->delete($course); + + $this->assertSame(0, $repo->count([])); + $this->assertSame(0, $courseRepo->count([])); + $this->assertSame(0, $publicationRelUserRepo->count([])); } public function testFindAllByCourse(): void diff --git a/tests/CourseBundle/Repository/CSurveyRepositoryTest.php b/tests/CourseBundle/Repository/CSurveyRepositoryTest.php index 7be9add67d..f52d71c665 100644 --- a/tests/CourseBundle/Repository/CSurveyRepositoryTest.php +++ b/tests/CourseBundle/Repository/CSurveyRepositoryTest.php @@ -6,7 +6,6 @@ declare(strict_types=1); namespace Chamilo\Tests\CourseBundle\Repository; -use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Repository\Node\CourseRepository; use Chamilo\CourseBundle\Entity\CSurvey; use Chamilo\CourseBundle\Entity\CSurveyAnswer; @@ -161,8 +160,7 @@ class CSurveyRepositoryTest extends AbstractApiTest $this->assertSame(1, $surveyOptionRepo->count([])); $this->assertSame(1, $courseRepo->count([])); - /** @var Course $course */ - $course = $courseRepo->find($course->getId()); + $course = $this->getCourse($course->getId()); $courseRepo->delete($course); $this->assertSame(0, $courseRepo->count([])); diff --git a/tests/CourseBundle/Repository/CThematicAdvanceRepositoryTest.php b/tests/CourseBundle/Repository/CThematicAdvanceRepositoryTest.php index d58929e059..8a116d671a 100644 --- a/tests/CourseBundle/Repository/CThematicAdvanceRepositoryTest.php +++ b/tests/CourseBundle/Repository/CThematicAdvanceRepositoryTest.php @@ -160,7 +160,7 @@ class CThematicAdvanceRepositoryTest extends AbstractApiTest $this->assertSame(1, $attendanceRepo->count([])); $this->assertSame(1, $advanceRepo->count([])); - $course = $courseRepo->find($course->getId()); + $course = $this->getCourse($course->getId()); $courseRepo->delete($course); $this->assertSame(0, $courseRepo->count([])); diff --git a/tests/CourseBundle/Repository/CThematicPlanRepositoryTest.php b/tests/CourseBundle/Repository/CThematicPlanRepositoryTest.php index f041ff2943..93d9e71aee 100644 --- a/tests/CourseBundle/Repository/CThematicPlanRepositoryTest.php +++ b/tests/CourseBundle/Repository/CThematicPlanRepositoryTest.php @@ -99,7 +99,7 @@ class CThematicPlanRepositoryTest extends AbstractApiTest $this->assertSame(1, $planRepo->count([])); $this->assertSame(1, $courseRepo->count([])); - $course = $courseRepo->find($course->getId()); + $course = $this->getCourse($course->getId()); $courseRepo->delete($course); $this->assertSame(0, $thematicRepo->count([]));