示例#1
0
 /**
  * Test add postalCode in zone
  *
  * @dataProvider dataAddAnyInZone
  */
 public function testAddPostalCodeInZone($exists, $persist, $flush)
 {
     $this->objectManager->expects($persist)->method('persist')->with($this->isInstanceOf('Elcodi\\Component\\Geo\\Entity\\Interfaces\\ZonePostalCodeMemberInterface'));
     $this->objectManager->expects($flush)->method('flush')->with($this->isInstanceOf('Elcodi\\Component\\Geo\\Entity\\Interfaces\\ZonePostalCodeMemberInterface'));
     $this->zoneMatcher->expects($this->any())->method('isPostalCodeContainedInZone')->will($this->returnValue($exists));
     $postalCode = $this->getMock('Elcodi\\Component\\Geo\\Entity\\Interfaces\\PostalCodeInterface');
     $zone = $this->getMock('Elcodi\\Component\\Geo\\Entity\\Interfaces\\ZoneInterface');
     $this->zoneManager->addPostalCodeToZone($zone, $postalCode);
 }
示例#2
0
 /**
  * Add a Postalcode to a Zone
  *
  * @param ZoneInterface       $zone       Zone
  * @param PostalCodeInterface $postalCode PostalCode
  *
  * @return $this self Object
  */
 public function addPostalcodeToZone(ZoneInterface $zone, PostalcodeInterface $postalCode)
 {
     $zoneHasPostalcode = $this->zoneMatcher->isPostalCodeContainedInZone($zone, $postalCode);
     if (!$zoneHasPostalcode) {
         $zonePostalcodeMember = new $this->zonePostalCodeMemberNamespace($zone, $postalCode);
         $zone->addMember($zonePostalcodeMember);
         $this->zoneMemberObjectManager->persist($zonePostalcodeMember);
         $this->zoneMemberObjectManager->flush($zonePostalcodeMember);
     }
     return $this;
 }
示例#3
0
 /**
  * Test add existing-already postalCode
  */
 public function testAddPostalCodeInZoneExistingPostalCode()
 {
     $existingPostalCode = $this->getMock('Elcodi\\Component\\Geo\\Entity\\Interfaces\\PostalCodeInterface');
     $anotherExistingPostalCode = $this->getMock('Elcodi\\Component\\Geo\\Entity\\Interfaces\\PostalCodeInterface');
     $postalCode = $this->getMock('Elcodi\\Component\\Geo\\Entity\\Interfaces\\PostalCodeInterface');
     $postalCode->expects($this->any())->method('equals')->will($this->returnCallback(function (PostalCodeInterface $postalCode) use($existingPostalCode) {
         return $postalCode === $existingPostalCode;
     }));
     $zone = $this->getMock('Elcodi\\Component\\Geo\\Entity\\Interfaces\\ZoneInterface');
     $zone->expects($this->any())->method('getMembers')->will($this->returnValue(new ArrayCollection([new ZonePostalCodeMember($zone, $existingPostalCode), new ZonePostalCodeMember($zone, $anotherExistingPostalCode)])));
     $isPostalCodeContainedInZone = $this->zoneMatcher->isPostalCodeContainedInZone($zone, $postalCode);
     $this->assertTrue($isPostalCodeContainedInZone);
 }