protected function createDistrict($code, $name, Province $province)
 {
     $communityEntity = new District($code);
     $communityEntity->setName($name)->setProvince($province);
     $this->kernel->getContainer()->get('doctrine')->getManager()->persist($communityEntity);
     $this->kernel->getContainer()->get('doctrine')->getManager()->flush();
 }
    function it_converts_node_to_community_with_updating_existing_one(ObjectManager $om, ObjectRepository $or, Community $community)
    {
        $xml = <<<EOT
<row>
    <col name="WOJ">02</col>
    <col name="POW">01</col>
    <col name="GMI">01</col>
    <col name="RODZ">1</col>
    <col name="NAZWA">Bolesławiec</col>
    <col name="NAZDOD">gmina miejska</col>
    <col name="STAN_NA">2013-01-01</col>
</row>
EOT;
        $district = new District(201);
        $district->setName('Bolesławiec');
        $communityType = new CommunityType(1);
        $communityType->setName('gmina miejska');
        $or->findOneBy(array('code' => 201))->shouldBeCalled()->willReturn($district);
        $or->findOneBy(array('type' => 1))->shouldBeCalled()->willReturn($communityType);
        $or->findOneBy(array('code' => 201011))->shouldBeCalled()->willReturn($community);
        $community->setName('Bolesławiec')->shouldBeCalled()->willReturn($community);
        $community->setType($communityType)->shouldBeCalled()->willReturn($community);
        $community->setDistrict($district)->shouldBeCalled()->willReturn($community);
        $this->beConstructedWith(new \SimpleXMLElement($xml), $om);
        $this->convertToEntity()->shouldBeLike($community);
    }