/**
  * @param $code
  * @param $name
  * @param $typeName
  * @param $districtName
  * @internal param $row
  */
 protected function createCommunity($code, $name, $typeName, $districtName)
 {
     $community = new Community($code);
     $community->setName($name)->setType($this->findCommunityTypeByName($typeName))->setDistrict($this->findDistrictByName($districtName));
     $this->kernel->getContainer()->get('doctrine')->getManager()->persist($community);
     $this->kernel->getContainer()->get('doctrine')->getManager()->flush();
 }
    function it_converts_node_to_community(ObjectManager $om, ObjectRepository $or)
    {
        $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);
        $expectedCommunity = new Community(201011);
        $expectedCommunity->setName('Bolesławiec')->setType($communityType)->setDistrict($district);
        $this->beConstructedWith(new \SimpleXMLElement($xml), $om);
        $this->convertToEntity()->shouldBeLike($expectedCommunity);
    }