Exemple #1
0
 /**
  * @expectedException \Oro\Bundle\EntityBundle\Exception\InvalidEntityException
  */
 public function testAddConnectionShouldNotAllowReconnect()
 {
     $obj = new Calendar();
     $connection = new CalendarConnection(new Calendar());
     $connection->setCalendar(new Calendar());
     $obj->addConnection($connection);
 }
 /**
  * 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;
 }
 public function testConstructor()
 {
     $calendar = new Calendar();
     $obj = new CalendarConnection($calendar);
     $this->assertEquals($calendar, $obj->getConnectedCalendar());
 }