private function resultLocation(Collection $location) { if (!$location->count()) { $this->setError('error'); return $this->view; } $this->view->locations = $location; return $this->view; }
public function testGetLocationCityAction() { $city = new Cities(array('id' => 7)); $collectionCity = new Collection(); $collectionCity->append($city); $dataLocation = array('id' => 5); $this->paramsMock->expects($this->once())->method('fromPost')->will($this->returnValue($dataLocation)); $this->cityFinderServiceMock->expects($this->once())->method('findMany')->with($this->equalTo(array('RoLocations' => array('Cities' => array('regionId' => $dataLocation['id'])))))->will($this->returnValue($collectionCity)); $resultView = $this->controller->getLocationCityAction($this->paramsMock, $this->cityFinderServiceMock); $this->assertSame($collectionCity, $resultView->locations); }
public function testDeleteAll_CriteriaNameDifferentToField_Delete() { $id = 1; $criteria = new Ids($id); $collection = new Collection(); $collection->append($this->entityMock); $this->criteriaFactoryMock->expects($this->once())->method('getNativeCriteria')->with($this->equalTo('Ids'), $this->equalTo($id))->will($this->returnValue($criteria)); $this->repositoryMock->expects($this->once())->method('findMany')->with($this->equalTo($criteria))->will($this->returnValue($collection)); $this->repositoryMock->expects($this->once())->method('deleteByAttribute')->with($this->equalTo($id), $this->equalTo('id')); $this->eventManagerMock->expects($this->once())->method('trigger')->with($this->equalTo('deleteAll:post'), $this->equalTo($this->service), $this->equalTo(array('collection' => $collection))); $result = $this->service->deleteAll($id, 'Ids'); $this->assertEquals($collection, $result); }
public function testGetAllByPages_NotEmptyCollection_ReturnCollectionByPages() { $page = 2; $limit = 2; $entity1 = new Entity(array('id' => 1)); $entity2 = new Entity(array('id' => 2)); $entity3 = new Entity(array('id' => 3)); $collection = new Collection(); $collection->offsetSet($entity1->getId(), $entity1); $collection->offsetSet($entity2->getId(), $entity2); $collection->offsetSet($entity3->getId(), $entity3); $collectionByPages = new Collection(); $collectionByPages->offsetSet($entity3->getId(), $entity3); $this->assertEquals($collectionByPages, $collection->getAllByPages($page, $limit)); }
public function testUpdateAllCriteriaNameDifferentToField() { $id = 1; $criteria = new Ids($id); $collection = new Collection(); $collection->append($this->entityMock); $data = array(); $this->criteriaFactoryMock->expects($this->once())->method('getNativeCriteria')->with($this->equalTo('Ids'), $this->equalTo($id))->will($this->returnValue($criteria)); $this->repositoryMock->expects($this->once())->method('findMany')->with($this->equalTo($criteria))->will($this->returnValue($collection)); $this->repositoryMock->expects($this->once())->method('updateByAttribute')->with($this->equalTo($data), $this->equalTo($id), $this->equalTo('id')); $result = $this->service->updateAll($id, 'Ids', $data); $this->assertEquals($collection, $result); }