コード例 #1
0
ファイル: SerializerTest.php プロジェクト: ramunasd/platform
 /**
  * @dataProvider normalizeDataProvider
  */
 public function testNormalize($proc, $procForCompare, $iterations)
 {
     $supportedNormalizer = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Serializer\\Normalizer\\NormalizerInterface');
     $supportedNormalizer->expects($this->exactly($iterations))->method('supportsNormalization')->will($this->returnValue(true));
     $nonSupportedNormalizer = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Serializer\\Normalizer\\NormalizerInterface');
     $nonSupportedNormalizer->expects($this->exactly($iterations))->method('supportsNormalization')->will($this->returnValue(false));
     $denormalizer = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Serializer\\Normalizer\\DenormalizerInterface');
     $this->serializer = new Serializer([$denormalizer, $nonSupportedNormalizer, $supportedNormalizer]);
     $this->serializer->supportsNormalization(new \stdClass());
     $this->serializer->normalize(new \stdClass(), null, [Serializer::PROCESSOR_ALIAS_KEY => $proc]);
     $this->serializer->normalize(new \stdClass(), null, [Serializer::PROCESSOR_ALIAS_KEY => $procForCompare]);
 }
コード例 #2
0
 /**
  * @param array $addresses
  *
  * @return array
  */
 protected function getPlainData(array $addresses = [])
 {
     $data = [];
     array_walk_recursive($addresses, function ($item, $key) use(&$data) {
         if ($item instanceof AbstractAddress) {
             $data[$key] = $this->serializer->normalize($item);
         }
     });
     return $data;
 }
コード例 #3
0
 /**
  * @param bool $isValid
  * @param array $submittedData
  * @param mixed $expectedData
  * @param mixed $defaultData
  * @param array $formErrors
  * @param array $groupedAddresses
  * @dataProvider submitWithPermissionProvider
  */
 public function testSubmitWithoutManualPermission($isValid, $submittedData, $expectedData, $defaultData, array $formErrors = [], array $groupedAddresses = [])
 {
     $this->serializer->expects($this->any())->method('normalize')->willReturn(['a_1' => ['street' => 'street']]);
     $this->orderAddressManager->expects($this->once())->method('getGroupedAddresses')->willReturn($groupedAddresses);
     $this->orderAddressManager->expects($this->any())->method('getEntityByIdentifier')->will($this->returnCallback(function ($identifier) use($groupedAddresses) {
         foreach ($groupedAddresses as $groupedAddressesGroup) {
             if (array_key_exists($identifier, $groupedAddressesGroup)) {
                 return $groupedAddressesGroup[$identifier];
             }
         }
         return null;
     }));
     $this->orderAddressManager->expects($this->any())->method('updateFromAbstract')->will($this->returnCallback(function (AccountAddress $address) {
         $orderAddress = new OrderAddress();
         $orderAddress->setCountry($address->getCountry());
         $orderAddress->setStreet($address->getStreet());
         return $orderAddress;
     }));
     $this->orderAddressSecurityProvider->expects($this->once())->method('isManualEditGranted')->willReturn(false);
     $this->checkForm($isValid, $submittedData, $expectedData, $defaultData, $formErrors);
 }