/** * @return array */ protected function getCalendarDefaultValues() { $result = $this->calendarPropertyProvider->getDefaultValues(); $result['calendarName'] = null; $result['removable'] = true; return $result; }
public function testGetItemsVisibilityCurrentCalendarOnly() { $calendarId = 123; $subordinate = false; $items = [['calendarAlias' => 'test', 'calendar' => 1, 'visible' => true]]; $repo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock(); $this->doctrineHelper->expects($this->once())->method('getEntityRepository')->with(CalendarPropertyProvider::CALENDAR_PROPERTY_CLASS)->will($this->returnValue($repo)); $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock(); $repo->expects($this->once())->method('createQueryBuilder')->with('o')->will($this->returnValue($qb)); $qb->expects($this->once())->method('select')->with('o.calendarAlias, o.calendar, o.visible')->will($this->returnSelf()); $qb->expects($this->once())->method('where')->with('o.targetCalendar = :calendar_id')->will($this->returnSelf()); $qb->expects($this->at(2))->method('setParameter')->with('calendar_id', $calendarId)->will($this->returnSelf()); $qb->expects($this->once())->method('andWhere')->with('o.calendarAlias = :alias AND o.calendar = :calendar_id')->will($this->returnSelf()); $qb->expects($this->at(4))->method('setParameter')->with('alias', Calendar::CALENDAR_ALIAS)->will($this->returnSelf()); $query = $this->getMockBuilder('Doctrine\\ORM\\AbstractQuery')->disableOriginalConstructor()->setMethods(['getArrayResult'])->getMockForAbstractClass(); $qb->expects($this->once())->method('getQuery')->will($this->returnValue($query)); $query->expects($this->once())->method('getArrayResult')->will($this->returnValue($items)); $result = $this->provider->getItemsVisibility($calendarId, $subordinate); $this->assertSame($items, $result); }