public function testFillEntityData() { $type = AddressType::TYPE_BILLING; $addressType = new AddressType($type); $this->assertEmpty($addressType->getLabel()); $this->fixture->fillEntityData($type, $addressType); $this->assertEquals(ucfirst($type) . ' Type', $addressType->getLabel()); }
public function testGetTypeLabels() { $this->assertEquals(array(), $this->address->getTypeLabels()); $billing = new AddressType('billing'); $billing->setLabel('Billing'); $this->address->addType($billing); $shipping = new AddressType('shipping'); $shipping->setLabel('Shipping'); $this->address->addType($shipping); $this->assertEquals(array('Billing', 'Shipping'), $this->address->getTypeLabels()); }
/** * Get address mock. * * @param array $addressTypes * @param bool $isEmpty * @return \PHPUnit_Framework_MockObject_MockObject */ protected function getTypedAddressMock(array $addressTypes, $isEmpty = false) { $address = $this->getMockBuilder('Oro\\Bundle\\AddressBundle\\Entity\\AbstractTypedAddress')->disableOriginalConstructor()->setMethods(array('getTypes', 'isEmpty'))->getMockForAbstractClass(); $addressTypeEntities = array(); foreach ($addressTypes as $name => $label) { $addressType = new AddressType($name); $addressType->setLabel($label); $addressTypeEntities[] = $addressType; } $address->expects($this->any())->method('getTypes')->will($this->returnValue($addressTypeEntities)); $address->expects($this->once())->method('isEmpty')->will($this->returnValue($isEmpty)); return $address; }
/** * {@inheritdoc} */ public function addType(AddressType $type) { if (!$this->hasTypeWithName($type->getName())) { $addressToType = $this->createAddressToAddressTypeEntity(); $addressToType->setType($type); $addressToType->setAddress($this); $this->types->add($addressToType); } return $this; }
/** * {@inheritdoc} */ protected function loadEntities(ObjectManager $manager) { $addressTypeRepository = $manager->getRepository('OroAddressBundle:AddressType'); $translationLocales = $this->getTranslationLocales(); $addressTypes = $this->getAddressTypes(); foreach ($translationLocales as $locale) { foreach ($addressTypes as $addressName) { // get address type entity /** @var AddressType $addressType */ $addressType = $addressTypeRepository->findOneBy(array('name' => $addressName)); if (!$addressType) { $addressType = new AddressType($addressName); } // set locale and label $addressTypeLabel = $this->translate($addressName, static::ADDRESS_TYPE_PREFIX, $locale); $addressType->setLocale($locale)->setLabel($addressTypeLabel); // save $manager->persist($addressType); } } $manager->flush(); }
public function testToString() { $this->assertEquals('', $this->type); $this->type->setLabel('Shipping'); $this->assertEquals('Shipping', (string) $this->type); }
/** * Gets one address that has specified type. * * @param AddressType $type * * @return ContactAddress|null */ public function getAddressByType(AddressType $type) { return $this->getAddressByTypeName($type->getName()); }
/** * @param AddressType $object * @param mixed $format * @param array $context * @return array */ public function normalize($object, $format = null, array $context = array()) { return $object->getName(); }
/** * Remove address type * * @param AddressType $type * @return CustomerAddress */ public function removeType(AddressType $type) { /** @var CustomerAddressToAddressType $addressesToType */ foreach ($this->getAddressesToTypes() as $addressesToType) { if ($addressesToType->getType()->getName() === $type->getName()) { $this->removeAddressesToType($addressesToType); } } return $this; }
/** * @param string $key * @param AddressType $entity */ public function fillEntityData($key, $entity) { $label = ucfirst($entity->getName()) . ' Type'; $entity->setLabel($label); }