当前位置: 首页>>代码示例>>PHP>>正文


PHP ManagerRegistry::expects方法代码示例

本文整理汇总了PHP中Symfony\Bridge\Doctrine\ManagerRegistry::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ManagerRegistry::expects方法的具体用法?PHP ManagerRegistry::expects怎么用?PHP ManagerRegistry::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Bridge\Doctrine\ManagerRegistry的用法示例。


在下文中一共展示了ManagerRegistry::expects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetDeleteMessageTextForDataGrid

 public function testGetDeleteMessageTextForDataGrid()
 {
     $paymentTermId = 1;
     $paymentTermRepository = $this->getMockBuilder('OroB2B\\Bundle\\PaymentBundle\\Entity\\Repository\\PaymentTermRepository')->disableOriginalConstructor()->getMock();
     $paymentTermRepository->expects($this->once())->method('find')->with($paymentTermId)->willReturnCallback(function ($id) {
         return new PaymentTermStub($id);
     });
     $om = $this->getMock('\\Doctrine\\Common\\Persistence\\ObjectManager');
     $om->expects($this->once())->method('getRepository')->with($this->equalTo('OroB2BPaymentBundle:PaymentTerm'))->willReturn($paymentTermRepository);
     $this->managerRegistry->expects($this->once())->method('getManagerForClass')->with($this->equalTo('OroB2BPaymentBundle:PaymentTerm'))->willReturn($om);
     $message = $this->extension->getDeleteMessageTextForDataGrid($paymentTermId);
     $this->assertDeleteMessage($message, $paymentTermId, 0, 0);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:13,代码来源:DeleteMessageTextGeneratorTest.php

示例2: testCreateTree

 /**
  * @dataProvider createTreeDataProvider
  * @param Page[] $pages
  * @param array $expected
  */
 public function testCreateTree($pages, array $expected)
 {
     $this->managerRegistry->expects($this->any())->method('getRepository')->with('OroB2BCMSBundle:Page')->willReturn($this->repository);
     $this->repository->expects($this->any())->method('getChildren')->with(null, false, 'left', 'ASC')->willReturn($pages);
     $result = $this->pageTreeHandler->createTree();
     $this->assertEquals($expected, $result);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:12,代码来源:PageTreeHandlerTest.php

示例3: prepareEmMock

 protected function prepareEmMock()
 {
     $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $metadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
     $repo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $entity = new Integration();
     $entity->setName(self::TEST_NAME);
     $entity->setType(self::TEST_TYPE);
     $this->registry->expects($this->once())->method('getManagerForClass')->with($this->equalTo($this->testEntityName))->will($this->returnValue($em));
     $em->expects($this->once())->method('getClassMetadata')->with($this->equalTo($this->testEntityName))->will($this->returnValue($metadata));
     $metadata->expects($this->once())->method('getSingleIdentifierFieldName')->will($this->returnValue(self::TEST_ID_FIELD_NAME));
     $em->expects($this->once())->method('getRepository')->with($this->equalTo($this->testEntityName))->will($this->returnValue($repo));
     $repo->expects($this->once())->method('find')->with($this->equalTo(self::TEST_ID))->will($this->returnValue($entity));
 }
开发者ID:CopeX,项目名称:crm,代码行数:14,代码来源:ChannelDatasourceTypeTest.php

示例4: prepare

 /**
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  *
  * @param array $config
  */
 protected function prepare($config)
 {
     $metadata = [];
     $fieldConfigs = [];
     foreach ($config as $entityClassName => $entityData) {
         $entityMetadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
         $entityMetadata->expects($this->any())->method('getName')->will($this->returnValue($entityClassName));
         $metadata[$entityClassName] = $entityMetadata;
         $fieldNames = [];
         $fieldTypes = [];
         $fieldIdentifiers = [];
         $configs = [];
         foreach ($entityData['fields'] as $fieldName => $fieldData) {
             $fieldNames[] = $fieldName;
             $fieldTypes[] = [$fieldName, $fieldData['type']];
             $fieldIdentifiers[] = [$fieldName, isset($fieldData['identifier']) ? $fieldData['identifier'] : false];
             $configId = new FieldConfigId('extend', $entityClassName, $fieldName, $fieldData['type']);
             $configs[] = new Config($configId);
         }
         $fieldConfigs[$entityClassName] = $configs;
         $entityMetadata->expects($this->any())->method('getFieldNames')->will($this->returnValue($fieldNames));
         $entityMetadata->expects($this->any())->method('hasField')->willReturnCallback(function ($name) use($fieldNames) {
             return in_array($name, $fieldNames, true);
         });
         $entityMetadata->expects($this->any())->method('isIdentifier')->will($this->returnValueMap($fieldIdentifiers));
         $relNames = [];
         $mappings = [];
         if (isset($entityData['relations'])) {
             $relTargetClasses = [];
             foreach ($entityData['relations'] as $relName => $relData) {
                 $type = $relData['type'];
                 $relTargetClass = $relData['target_class'];
                 if ($type === 'ref-one') {
                     $mappings[$relName] = $relData;
                 }
                 $fieldTypes[] = [$relName, $type];
                 $relNames[] = $relName;
                 $relTargetClasses[] = [$relName, $relTargetClass];
             }
             $entityMetadata->expects($this->any())->method('getAssociationTargetClass')->will($this->returnValueMap($relTargetClasses));
             $entityMetadata->expects($this->any())->method('getAssociationMappedByTargetField')->will($this->returnValue('id'));
         }
         $entityMetadata->expects($this->any())->method('getAssociationNames')->will($this->returnValue($relNames));
         $entityMetadata->expects($this->any())->method('hasAssociation')->willReturnCallback(function ($name) use($relNames) {
             return in_array($name, $relNames, true);
         });
         if (isset($entityData['unidirectional_relations'])) {
             foreach ($entityData['unidirectional_relations'] as $relName => $relData) {
                 $fieldTypes[] = [$relName, $relData['type']];
                 $relData['fieldName'] = $relName;
                 $relData['isOwningSide'] = true;
                 $relData['inversedBy'] = null;
                 $relData['sourceEntity'] = $entityClassName;
                 unset($relData['config']);
                 $mappings[$relName] = $relData;
             }
             $entityMetadata->expects($this->any())->method('getAssociationMappings')->will($this->returnValue($mappings));
         }
         $entityMetadata->expects($this->any())->method('isSingleValuedAssociation')->will($this->returnCallback(function ($field) use($mappings) {
             return !empty($mappings[$field]);
         }));
         $entityMetadata->expects($this->any())->method('getTypeOfField')->will($this->returnValueMap($fieldTypes));
     }
     $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $metadataFactory = $this->getMock('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $em->expects($this->any())->method('getMetadataFactory')->will($this->returnValue($metadataFactory));
     $metadataFactory->expects($this->any())->method('getMetadataFor')->will($this->returnCallback(function ($entityClassName) use(&$metadata) {
         return $metadata[$entityClassName];
     }));
     $this->doctrine->expects($this->any())->method('getManagerForClass')->with($this->isType('string'))->will($this->returnValue($em));
     $this->extendConfigProvider->expects($this->any())->method('getConfigs')->will($this->returnCallback(function ($className) use($fieldConfigs) {
         return $fieldConfigs[$className];
     }));
     $this->entityConfigProvider->expects($this->any())->method('hasConfig')->will($this->returnCallback(function ($className, $fieldName) use(&$config) {
         if (isset($config[$className])) {
             if ($fieldName === null) {
                 return true;
             }
             if (isset($config[$className]['fields'][$fieldName]['config'])) {
                 return true;
             }
             if (isset($config[$className]['relations'][$fieldName]['config'])) {
                 return true;
             }
             if (isset($config[$className]['unidirectional_relations'][$fieldName]['config'])) {
                 return true;
             }
         }
         return false;
     }));
     $this->entityConfigProvider->expects($this->any())->method('getConfig')->will($this->returnCallback(function ($className, $fieldName) use(&$config) {
         if (isset($config[$className])) {
             if ($fieldName === null) {
//.........这里部分代码省略.........
开发者ID:sagikazarmark,项目名称:platform,代码行数:101,代码来源:EntityFieldProviderTest.php


注:本文中的Symfony\Bridge\Doctrine\ManagerRegistry::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。