예제 #1
0
 /**
  * @covers Ilios\CoreBundle\Entity\Manager\CourseManager::findCoursesBy
  */
 public function testFindCoursesDoNotIncludeDeleted()
 {
     $class = 'Ilios\\CoreBundle\\Entity\\Course';
     $em = m::mock('Doctrine\\ORM\\EntityManager');
     $repository = m::mock('Doctrine\\ORM\\Repository')->shouldReceive('findBy')->with(array('foo' => 'bar', 'deleted' => false), null, null, null)->mock();
     $registry = m::mock('Doctrine\\Bundle\\DoctrineBundle\\Registry')->shouldReceive('getManagerForClass')->andReturn($em)->shouldReceive('getRepository')->andReturn($repository)->mock();
     $manager = new CourseManager($registry, $class);
     $manager->findCoursesBy(array('foo' => 'bar'));
 }
예제 #2
0
 /**
  * @covers \Ilios\CoreBundle\Entity\Manager\CourseManager::delete
  */
 public function testDeleteCourse()
 {
     $class = 'Ilios\\CoreBundle\\Entity\\Course';
     $em = m::mock('Doctrine\\ORM\\EntityManager')->shouldReceive('remove')->shouldReceive('flush')->mock();
     $repository = m::mock('Doctrine\\ORM\\Repository');
     $registry = m::mock('Doctrine\\Bundle\\DoctrineBundle\\Registry')->shouldReceive('getManagerForClass')->andReturn($em)->shouldReceive('getRepository')->andReturn($repository)->mock();
     $entity = m::mock($class);
     $manager = new CourseManager($registry, $class);
     $manager->delete($entity);
 }
예제 #3
0
 /**
  * @param int $courseId
  * @param int $owningSchoolId
  * @param UserInterface $user
  *
  * @return bool
  */
 protected function isViewGranted($courseId, $owningSchoolId, UserInterface $user)
 {
     // grant VIEW privileges if at least one of the following
     // statements is true:
     // 1. the user's primary school is the course's owning school
     // 2. the user is instructing ILMs or offerings in this course
     // 3. the user is directing this course
     // 4. the user has READ rights on the course's owning school via the permissions system
     // 5. the user has READ rights on the course via the permissions system
     return $owningSchoolId === $user->getSchool()->getId() || $this->courseManager->isUserInstructingInCourse($user, $courseId) || $user->isDirectingCourse($courseId) || $this->permissionManager->userHasReadPermissionToSchool($user, $owningSchoolId) || $this->permissionManager->userHasReadPermissionToCourse($user, $courseId);
 }
예제 #4
0
 /**
  * @param Registry $em
  * @param string $class
  * @param FormFactoryInterface $formFactory
  */
 public function __construct(Registry $em, $class, FormFactoryInterface $formFactory)
 {
     $this->formFactory = $formFactory;
     parent::__construct($em, $class);
 }