public function testSetOrganizationForPublic() { $obj = new SystemCalendar(); $obj->setPublic(true); $this->assertTrue($obj->isPublic()); $this->assertNull($obj->getOrganization()); $obj->setOrganization(new Organization()); $this->assertNull($obj->getOrganization()); }
/** * @expectedException \Oro\Bundle\SecurityBundle\Exception\ForbiddenException * @expectedExceptionMessage Access denied. */ public function testHandleDeleteWhenPublicCalendarDeleteNotGranted() { $calendar = new SystemCalendar(); $calendar->setPublic(true); $this->manager->expects($this->once())->method('find')->will($this->returnValue($calendar)); $this->calendarConfig->expects($this->once())->method('isPublicCalendarEnabled')->will($this->returnValue(true)); $this->securityFacade->expects($this->once())->method('isGranted')->with('oro_public_calendar_management')->will($this->returnValue(false)); $this->handler->handleDelete(1, $this->manager); }
/** * Test update of public calendar */ public function testPreUpdatePublicCalendar() { $entity = new SystemCalendar(); $entity->setOrganization(new Organization()); $this->assertNotNull($entity->getOrganization()); $changeSet = []; $args = new PreUpdateEventArgs($entity, $this->em, $changeSet); $entity->setPublic(true); $this->listener->preUpdate($args); $this->assertNull($entity->getOrganization()); }
public function testSetPublicCalendar() { $calendarId = 123; $calendar = new SystemCalendar(); $calendar->setPublic(true); ReflectionUtil::setId($calendar, $calendarId); $event = new CalendarEvent(); $this->calendarConfig->expects($this->once())->method('isPublicCalendarEnabled')->will($this->returnValue(true)); $repo = $this->getMockBuilder('Oro\\Bundle\\CalendarBundle\\Entity\\Repository\\SystemCalendarRepository')->disableOriginalConstructor()->getMock(); $this->doctrineHelper->expects($this->once())->method('getEntityRepository')->with('OroCalendarBundle:SystemCalendar')->will($this->returnValue($repo)); $repo->expects($this->once())->method('find')->with($calendarId)->will($this->returnValue($calendar)); $this->manager->setCalendar($event, SystemCalendar::PUBLIC_CALENDAR_ALIAS, $calendarId); $this->assertSame($calendar, $event->getSystemCalendar()); }