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); }
/** * @dataProvider GetAllByAttributeValueProvider */ public function testGetAllByAttributeValue_WithHtmlEntities($value, $collectionValue) { $entity = new Entity(array('id' => $collectionValue)); $collection = new Collection(); $collection->append($entity); $expectedCollection = new Collection(); $expectedCollection->offsetSet($entity->getId(), $entity); $this->assertEquals($expectedCollection, $collection->getAllByAttributeValue($value)); }
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); }