function it_converts_node_to_place_entry(ObjectManager $om, ObjectRepository $or) { $xml = <<<EOT <row> <col name="WOJ">04</col> <col name="POW">11</col> <col name="GMI">05</col> <col name="RODZ_GMI">5</col> <col name="RM">01</col> <col name="MZ">1</col> <col name="NAZWA">Rzeczyca</col> <col name="SYM">0867650</col> <col name="SYMPOD">0867650</col> <col name="STAN_NA">2013-03-06</col> </row> EOT; $community = new Community(41105); $placeType = new Type(1); $placeType->setName('miasto'); $or->findOneBy(array('code' => 411055))->shouldBeCalled()->willReturn($community); $or->findOneBy(array('type' => 1))->shouldBeCalled()->willReturn($placeType); $place = new Place(867650); $place->setName('Rzeczyca')->setType($placeType)->setCommunity($community); $this->beConstructedWith(new \SimpleXMLElement($xml), $om); $this->convertToEntity()->shouldBeLike($place); }
function it_converts_node_to_street_entry_with_updating_existing_one(ObjectManager $om, ObjectRepository $or, Street $street) { $xml = <<<EOT <row> <col name="WOJ">02</col> <col name="POW">23</col> <col name="GMI">09</col> <col name="RODZ_GMI">2</col> <col name="SYM">0884849</col> <col name="SYM_UL">10268</col> <col name="CECHA">ul.</col> <col name="NAZWA_1">Księżycowa </col> <col name="NAZWA_2"/> <col name="STAN_NA">2013-10-10</col> </row> EOT; $place = new Place(884849); $place->setName('City'); $or->findOneBy(array('id' => '0884849'))->shouldBeCalled()->willReturn($place); $or->findOneBy(array('id' => '10268', 'place' => $place))->shouldBeCalled()->willReturn($street); $street->setName('Księżycowa')->shouldBeCalled()->willReturn($street); $street->setAdditionalName('')->shouldBeCalled()->willReturn($street); $street->setType('ul.')->shouldBeCalled()->willReturn($street); $this->beConstructedWith(new \SimpleXMLElement($xml), $om); $this->convertToEntity()->shouldBeLike($street->getWrappedObject()); }
protected function createPlace($id, $name, $typeName = null, $communityName = null) { $place = new Place($id); $place->setName($name); if (isset($typeName)) { $place->setType($this->findPlaceTypeByName($typeName)); } if (isset($communityName)) { $place->setCommunity($this->findCommunityByName($communityName)); } $this->kernel->getContainer()->get('doctrine')->getManager()->persist($place); $this->kernel->getContainer()->get('doctrine')->getManager()->flush(); }