/** * {@inheritdoc} */ public function apply(Request $request, ParamConverter $configuration) { $name = $configuration->getName(); $slug = $request->get($name); $elect = $this->electsService->getElectFromSlug($slug); $request->attributes->set('elect', $elect); return true; }
/** * Test get Mandates for FR. * * @see ElectsService::getElectsFromZone */ public function testGetMandates() { $isoCode = 'FR'; $country = $this->getMockBuilder(Country::class)->disableOriginalConstructor()->getMock(); $country->expects($this->any())->method('getIsoCode2Letters')->will($this->returnValue($isoCode)); $manager = $this->getManager(); $manager->expects($this->once())->method('getDBResults')->will($this->returnValue($this->fixtures->mandates)); $service = new ElectsService($manager, new RepresentationHydrator()); $mandates = $service->getMandates($country); $this->assertEquals(count($this->fixtures->mandates), count($mandates)); foreach ($mandates as $mandate) { $this->assertInstanceOf(Mandate::class, $mandate); } }