Пример #1
0
 /**
  * Connects another calendar to this calendar
  *
  * @param CalendarConnection $connection
  * @return Calendar
  * @throws InvalidEntityException
  */
 public function addConnection(CalendarConnection $connection)
 {
     if ($connection->getCalendar() !== null) {
         throw new InvalidEntityException("The already connected calendar cannot be re-connected.");
     }
     if ($connection->getConnectedCalendar() === null) {
         throw new InvalidEntityException("The connected calendar must be specified.");
     }
     if (!$this->connections->contains($connection)) {
         $connection->setCalendar($this);
         $this->connections->add($connection);
     }
     return $this;
 }
Пример #2
0
 public function testConstructor()
 {
     $calendar = new Calendar();
     $obj = new CalendarConnection($calendar);
     $this->assertEquals($calendar, $obj->getConnectedCalendar());
 }