/** * @param Channel $channel * @param mixed $entity */ public function refreshChannel(ZohoEntityType $entity, Channel $channel) { if ($channel->getId()) { $channel = $this->oroProvider->getChannelById($channel->getId()); $entity->setChannel($channel); } }
/** * @dataProvider gridProvider * * @param array $requestData */ public function testGrid($requestData) { $gridName = $requestData['gridParameters']['gridName']; $expectedResultCount = (int) $requestData['expectedResultCount']; $shouldPassIdentifier = isset($requestData['gridParameters']['id']); $shouldPassIntegration = isset($requestData['gridParameters']['channel']); $shouldAssertData = $expectedResultCount === 1; if ($shouldPassIdentifier) { $paramName = $gridName . '[' . $requestData['gridParameters']['id'] . ']'; $requestData['gridParameters'][$paramName] = $this->getMainEntityId(); } if ($shouldPassIntegration) { $paramName = $gridName . '[' . $requestData['gridParameters']['channel'] . ']'; $requestData['gridParameters'][$paramName] = self::$integration->getId(); } $this->client->requestGrid($requestData['gridParameters'], $requestData['gridFilters']); $response = $this->client->getResponse(); $result = $this->getJsonResponseContent($response, 200); foreach ($result['data'] as $row) { if ($shouldAssertData) { foreach ($requestData['assert'] as $fieldName => $value) { $this->assertEquals($value, $row[$fieldName]); } break; } } $this->assertCount($expectedResultCount, $result['data']); }
/** * @return Channel */ protected function getChannel() { if ($this->channel === null || $this->context->getOption('channel') !== $this->channel->getId()) { $this->channel = $this->connectorContextMediator->getChannel($this->context); } return $this->channel; }
public function transformDataProvider() { $integration = new Integration(); $integration->setType(self::TEST_TYPE); $integration->setName(self::TEST_NAME); return ['should return null if empty data given' => ['$data' => null, '$expectedResult' => null], 'should return null if bad data given' => ['$data' => ['testBadData'], '$expectedResult' => null], 'should convert to expected array' => ['$data' => $integration, '$expectedResult' => ['type' => self::TEST_TYPE, 'data' => null, 'identifier' => $integration, 'name' => self::TEST_NAME]]]; }
/** * @dataProvider gridProvider * * @param array $requestData */ public function testGrid($requestData) { $gridName = $requestData['gridParameters']['gridName']; $expectedResultCount = (int) $requestData['expectedResultCount']; $shouldPassIdentifier = array_key_exists('id', $requestData['gridParameters']); $shouldPassIntegration = array_key_exists('channel', $requestData['gridParameters']); $shouldPassRemoved = array_key_exists('is_removed', $requestData['gridParameters']); $shouldAssertData = $expectedResultCount === 1; if ($shouldPassIdentifier) { $paramName = $gridName . '[' . $requestData['gridParameters']['id'] . ']'; $requestData['gridParameters'][$paramName] = $this->getMainEntityId(); } if ($shouldPassIntegration) { $paramName = $gridName . '[' . $requestData['gridParameters']['channel'] . ']'; $requestData['gridParameters'][$paramName] = self::$integration->getId(); } if ($shouldPassRemoved) { $paramName = $gridName . '[' . $requestData['gridParameters']['is_removed'] . ']'; $requestData['gridParameters'][$paramName] = $requestData['gridFilters']['magento-cart-grid[_filter][is_removed][value]']; } $this->client->requestGrid($requestData['gridParameters'], $requestData['gridFilters']); $response = $this->client->getResponse(); $result = $this->getJsonResponseContent($response, 200); foreach ($result['data'] as $row) { if ($shouldAssertData) { foreach ($requestData['assert'] as $fieldName => $value) { $this->assertEquals($value, $row[$fieldName], sprintf('Incorrect value for %s', $fieldName)); } break; } } $this->assertCount($expectedResultCount, $result['data']); }
/** * Remove workflow records * * @param string $entityClassName * * @return $this */ protected function removeWorkflowDefinitions($entityClassName) { $workflowMetadata = $this->em->getClassMetadata('OroWorkflowBundle:WorkflowItem'); $entityMetadata = $this->em->getClassMetadata($entityClassName); $this->em->getConnection()->executeQuery(sprintf('Delete FROM %s WHERE id IN (SELECT o.workflow_item_id FROM %s o WHERE o.channel_id=%s)', $workflowMetadata->getTableName(), $entityMetadata->getTableName(), $this->channel->getId())); return $this; }
public function testProcessGoodScenario() { $testWebsiteId = 1; $testStoreId = 2; $testStoresArray = new \ArrayIterator([['website_id' => $testWebsiteId, 'store_id' => $testStoreId]]); $settingBag = new ParameterBag(['website_id' => $testWebsiteId]); $testData = [['id' => 1, 'originId' => 11], ['id' => 2, 'originId' => 22], ['id' => 3, 'originId' => 33]]; $testExistedCarts = [(object) ['entity_id' => 22]]; $repo = $this->getMockBuilder('OroCRM\\Bundle\\MagentoBundle\\Entity\\Repository\\CartRepository')->disableOriginalConstructor()->getMock(); $this->em->expects($this->any())->method('getRepository')->with('OroCRMMagentoBundle:Cart')->will($this->returnValue($repo)); $transport = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport')->setMethods(['getSettingsBag'])->getMockForAbstractClass(); $transport->expects($this->any())->method('getSettingsBag')->will($this->returnValue($settingBag)); $realTransport = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Provider\\Transport\\MagentoTransportInterface'); $realTransport->expects($this->once())->method('isSupportedExtensionVersion')->will($this->returnValue(true)); $realTransport->expects($this->once())->method('getStores')->will($this->returnValue($testStoresArray)); $this->helper->expects($this->once())->method('getTransport')->will($this->returnValue($realTransport)); $channel = new Channel(); $channel->setTransport($transport); $realTransport->expects($this->at(3))->method('call')->with(SoapTransport::ACTION_ORO_CART_LIST, ['filters' => ['complex_filter' => [['key' => 'store_id', 'value' => ['key' => 'in', 'value' => $testStoreId]], ['key' => 'entity_id', 'value' => ['key' => 'in', 'value' => '11,22']]]], 'pager' => ['page' => 1, 'pageSize' => self::BATCH_SIZE]])->will($this->returnValue($testExistedCarts)); $realTransport->expects($this->at(4))->method('call')->with(SoapTransport::ACTION_ORO_CART_LIST, ['filters' => ['complex_filter' => [['key' => 'store_id', 'value' => ['key' => 'in', 'value' => $testStoreId]], ['key' => 'entity_id', 'value' => ['key' => 'in', 'value' => '33']]]], 'pager' => ['page' => 1, 'pageSize' => self::BATCH_SIZE]])->will($this->returnValue([])); $repo->expects($this->once())->method('getCartsByChannelIdsIterator')->with($channel)->will($this->returnValue($testData)); $repo->expects($this->at(1))->method('markExpired')->with([1]); $repo->expects($this->at(2))->method('markExpired')->with([3]); $this->processor->process($channel); }
/** * @dataProvider addressTypesUpdateDataProvider * * @param string $priority * @param ArrayCollection $remoteTypes * @param ArrayCollection $localTypes * @param ArrayCollection $contactTypes * @param array $expectedTypeNames */ public function testAddressTypesUpdate($priority, ArrayCollection $remoteTypes, ArrayCollection $localTypes, ArrayCollection $contactTypes, array $expectedTypeNames) { $channel = new Channel(); $channel->getSynchronizationSettingsReference()->offsetSet('syncPriority', $priority); $testCountry = new Country('US'); $contact = new Contact(); $contactAddress = new ContactAddress(); $contactAddress->setId(self::TEST_CONTACT_ADDRESS_ID); $contactAddress->setTypes($contactTypes); $contactAddress->setCountry($testCountry); $contact->addAddress($contactAddress); $phone = new ContactPhone(); $phone->setPhone('123-123-123'); $phone->setOwner($contact); $contact->addPhone($phone); $localCustomer = new Customer(); $localAddress = new Address(); $localAddress->setContactAddress($contactAddress); $localAddress->setTypes($localTypes); $localAddress->setCountry($testCountry); $localAddress->setPhone('123-123-123'); $localAddress->setContactPhone($phone); $localCustomer->addAddress($localAddress); $remoteCustomer = new Customer(); $remoteAddress = new Address(); $remoteAddress->setContactAddress($contactAddress); $remoteAddress->setTypes($remoteTypes); $remoteAddress->setCountry($testCountry); $remoteAddress->setContactPhone($phone); $remoteCustomer->addAddress($remoteAddress); $helper = $this->getHelper($channel); $helper->merge($remoteCustomer, $localCustomer, $contact); $this->assertCount(1, $contact->getAddresses()); $this->assertEquals($expectedTypeNames, $contactAddress->getTypeNames()); }
public function testSchedule() { $testIntegrationType = 'testIntegrationType'; $testConnectorType = 'testConnectorType'; $testId = 22; $integration = new Integration(); $integration->setType($testIntegrationType); $integration->setEnabled(true); $ref = new \ReflectionProperty(get_class($integration), 'id'); $ref->setAccessible(true); $ref->setValue($integration, $testId); $this->typesRegistry->addChannelType($testIntegrationType, new TestIntegrationType()); $this->typesRegistry->addConnectorType($testConnectorType, $testIntegrationType, new TestTwoWayConnector()); $that = $this; $uow = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock(); $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($uow)); $metadataFactory = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadataFactory')->disableOriginalConstructor()->getMock(); $metadataFactory->expects($this->once())->method('getMetadataFor')->will($this->returnValue(new ClassMetadata('testEntity'))); $this->em->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metadataFactory)); $uow->expects($this->once())->method('persist')->with($this->isInstanceOf('JMS\\JobQueueBundle\\Entity\\Job'))->will($this->returnCallback(function (Job $job) use($that, $testId, $testConnectorType) { $expectedArgs = ['--integration=' . $testId, sprintf('--connector=testConnectorType', $testConnectorType), '--params=a:0:{}']; $that->assertEquals($expectedArgs, $job->getArgs()); })); $uow->expects($this->once())->method('computeChangeSet'); $this->scheduler->schedule($integration, $testConnectorType, [], false); }
/** * @param Integration $integration * @return Integration|null */ protected function getIntegration(Integration $integration) { if (!$integration->getId()) { return null; } $oldIntegration = $this->em->find('OroIntegrationBundle:Channel', $integration->getId()); return $oldIntegration ? clone $oldIntegration : null; }
public function testInterface() { $channel = new Integration(); $someOwner = $this->getMock('Oro\\Bundle\\UserBundle\\Entity\\User'); $channel->setDefaultUserOwner($someOwner); $event = new DefaultOwnerSetEvent($channel); $this->assertSame($channel, $event->getChannel()); $this->assertSame($someOwner, $event->getDefaultUserOwner()); }
/** * @Route("/create/{type}/{channelName}", requirements={"type"="\w+"}, name="orocrm_channel_integration_create") * @AclAncestor("oro_integration_create") * @Template("OroCRMChannelBundle:ChannelIntegration:update.html.twig") */ public function createAction($type, $channelName = null) { $translator = $this->get('translator'); $integrationName = urldecode($channelName) . ' ' . $translator->trans('orocrm.channel.data_source.label'); $integration = new Integration(); $integration->setType(urldecode($type)); $integration->setName(trim($integrationName)); return $this->update($integration); }
/** * @ TransportInterface $transport */ public function initFromContext() { $this->transport = $this->contextMediator->getTransport($this->getContext(), true); $this->channel = $this->contextMediator->getChannel($this->getContext()); if (!$this->transport) { throw new \InvalidArgumentException('Transport was not provided'); } $this->transport->init($this->channel->getTransport()); }
public function testTransportRelation() { $transport = $this->getMockForAbstractClass('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport'); $this->assertAttributeEmpty('transport', $this->entity); $this->entity->setTransport($transport); $this->assertSame($transport, $this->entity->getTransport()); $this->entity->clearTransport(); $this->assertAttributeEmpty('transport', $this->entity); }
/** * @param Integration $integration * @param bool $markReadOnly * * @return TransportInterface */ public function getInitializedTransport(Integration $integration, $markReadOnly = false) { if (!empty($this->transportByIntegration[$integration->getId()])) { return $this->transportByIntegration[$integration->getId()]; } $transport = $this->getTransport($integration, $markReadOnly); $transport->init($integration->getTransport()); $this->transportByIntegration[$integration->getId()] = $transport; return $transport; }
protected function setUp() { $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $this->connection = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock(); $this->em->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection)); $this->connection->expects($this->any())->method('beginTransaction'); $this->deleteManager = new DeleteManager($this->em); $this->deleteManager->addProvider(new TestIntegrationDeleteProvider()); $this->testIntegration = new Integration(); $this->testIntegration->setType('test'); }
public function testDeleteChannel() { $oldChannel = clone $this->channel; $this->client->request('DELETE', $this->getUrl('oro_api_delete_integration', ['id' => $this->channel->getId()])); $result = $this->client->getResponse(); $this->assertEmptyResponseStatusCodeEquals($result, 204); $this->assertNull($this->getChannel()); $this->assertNull($this->getCartByChannel($oldChannel)); $this->assertNull($this->getOrderByChannel($oldChannel)); $this->assertNull($this->getCustomerByChannel($oldChannel)); }
/** * @expectedException \LogicException * @expectedExceptionMessage Unable to schedule job for "testConnectorType" connector type */ public function testScheduleConnectorError() { $testIntegrationType = 'testIntegrationType'; $testConnectorType = 'testConnectorType'; $integration = new Integration(); $integration->setType($testIntegrationType); $this->typesRegistry->addChannelType($testIntegrationType, new TestIntegrationType()); $this->typesRegistry->addConnectorType($testConnectorType, $testIntegrationType, new TestConnector()); $integration->setEnabled(true); $this->scheduler->schedule($integration, $testConnectorType); }
public function testGetChannelFromContext() { $testID = 1; $integration = new Integration(); $integration->setTransport($this->getMockForAbstractClass('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport')); $context = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface'); $context->expects($this->once())->method('getOption')->with('channel')->will($this->returnValue($testID)); $this->repo->expects($this->once())->method('getOrLoadById')->with($testID)->will($this->returnValue($integration)); $result = $this->contextMediator->getChannel($context); $this->assertEquals($integration, $result); }
/** * @return array */ public function defaultIntegrationOwnerProvider() { $integrationEmptyOwner = new Integration(); $user = $this->getMock('Oro\\Bundle\\UserBundle\\Entity\\User'); $organization = $this->getMock('Oro\\Bundle\\OrganizationBundle\\Entity\\Organization'); $integrationWithOwner = new Integration(); $integrationWithOwner->setDefaultUserOwner($user); $integrationWithOrganization = new Integration(); $integrationWithOrganization->setOrganization($organization); return ['should set, user given and user owned entity' => [$integrationWithOwner, 'USER', false, true], 'should set with reload' => [$integrationWithOwner, 'USER', true, true], 'should not set, user not given even if user owned entity' => [$integrationEmptyOwner, 'USER', false, false], 'should not set, user given and BU owned entity' => [$integrationWithOwner, 'BUSINESS_UNIT', false, false], 'set organization' => [$integrationWithOrganization, 'BUSINESS_UNIT', false, false, true]]; }
/** * {@inheritdoc} */ protected function initializeFromContext(ContextInterface $context) { $this->transport = $this->contextMediator->getTransport($context, true); $this->channel = $this->contextMediator->getChannel($context); $this->validateConfiguration(); $this->transport->init($this->channel->getTransport()); $this->setSourceIterator($this->getConnectorSource()); if ($this->getSourceIterator() instanceof LoggerAwareInterface) { $this->getSourceIterator()->setLogger($this->logger); } }
public function testOnChannelSucceedSave() { $this->entity->setEntities(['OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity1', 'OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity2']); $this->event->expects($this->once())->method('getChannel')->will($this->returnValue($this->entity)); $this->settingProvider->expects($this->at(0))->method('getIntegrationConnectorName')->with('OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity1')->will($this->returnValue('TestConnector1')); $this->settingProvider->expects($this->at(1))->method('getIntegrationConnectorName')->with('OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity2')->will($this->returnValue('TestConnector2')); $this->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->em)); $this->em->expects($this->once())->method('persist')->with($this->integration); $this->em->expects($this->once())->method('flush'); $channelSaveSucceedListener = new ChannelSaveSucceedListener($this->settingProvider, $this->registry); $channelSaveSucceedListener->onChannelSucceedSave($this->event); $this->assertEquals($this->integration->getConnectors(), ['TestConnector1', 'TestConnector2']); }
/** * @param Integration $integration * * @param bool $optional * * @throws \LogicException * @return null|Channel */ public function getChannel(Integration $integration, $optional = false) { $this->ensureInitialized(); if (isset($this->integrationToChannelMap[$integration->getId()])) { /** @var EntityManager $em */ $em = $this->registry->getManager(); $id = $this->integrationToChannelMap[$integration->getId()]; $channel = $em->getPartialReference('OroCRMChannelBundle:Channel', $id); return $channel; } elseif (!$optional) { throw new \LogicException('Unable to find channel for given integration'); } return null; }
/** * @param ChannelRepository $repository * @param Channel $integration * @param string $connector */ protected function addInitialStatus(ChannelRepository $repository, Channel $integration, $connector) { /** @var MagentoSoapTransport $transport */ $transport = $integration->getTransport(); $syncStartDate = $transport->getSyncStartDate(); $now = new \DateTime('now', new \DateTimeZone('UTC')); $status = new Status(); $status->setData([AbstractInitialProcessor::INITIAL_SYNCED_TO => $syncStartDate->format(\DateTime::ISO8601)]); $status->setConnector($connector); $status->setDate($now); $status->setChannel($integration); $status->setCode(Status::STATUS_COMPLETED); $status->setMessage('Automatically added initial connector status.'); $repository->addStatus($integration, $status); }
/** * Populate owner to target entity based on integration configuration and entity's ownership type * * @param object $entity * @param Integration $integration */ public function populateChannelOwner($entity, Integration $integration) { $defaultUserOwner = $integration->getDefaultUserOwner(); $className = ClassUtils::getClass($entity); $doctrineMetadata = $this->getEm()->getClassMetadata($className); $ownershipMetadata = $this->getMetadata($className); if ($defaultUserOwner && $ownershipMetadata->isBasicLevelOwned()) { $defaultUserOwner = $this->ensureNotDetached($defaultUserOwner); $doctrineMetadata->setFieldValue($entity, $ownershipMetadata->getOwnerFieldName(), $defaultUserOwner); } $defaultOrganization = $integration->getOrganization(); if ($defaultOrganization && $ownershipMetadata->getGlobalOwnerFieldName()) { $defaultOrganization = $this->ensureNotDetached($defaultOrganization); $doctrineMetadata->setFieldValue($entity, $ownershipMetadata->getGlobalOwnerFieldName(), $defaultOrganization); } }
public function testWithFlush() { $this->assertEmpty($this->getScheduledJobs(), 'Should be empty before test'); $registry = $this->getContainer()->get('oro_integration.manager.types_registry'); $integrationType = uniqid('testIntegrationType', true); $connectorType = uniqid('testConnectorType', true); $registry->addChannelType($integrationType, new TestIntegrationType()); $registry->addConnectorType($connectorType, $integrationType, new TestTwoWayConnector()); $integration = new Integration(); $integration->setType($integrationType); $this->getContainer()->get('oro_integration.sync_scheduler')->schedule($integration, $connectorType); $jobs = $this->getScheduledJobs(); $this->assertNotEmpty($jobs); $this->getContainer()->get('oro_integration.sync_scheduler')->schedule($integration, $connectorType); $jobs = $this->getScheduledJobs(); $this->assertCount(1, $jobs, 'Should check do look up for already scheduled pending jobs'); }
/** * @dataProvider testProcessDataProvider */ public function testProcess($data, $expected) { $this->integration->expects($this->once())->method('getConnectors')->willReturn($data['integrationConnectors']); $this->integration->expects($this->any())->method('getId')->willReturn($data['channel']); $this->integration->expects($this->atLeastOnce())->method('getType')->willReturn($data['integrationType']); $this->integration->expects($this->once())->method('isEnabled')->willReturn(true); $this->registry->expects($this->any())->method('getConnectorType')->willReturnMap($data['realConnectorsMap']); $this->processorRegistry->expects($this->any())->method('getProcessorAliasesByEntity')->willReturn([]); $jobResult = new JobResult(); $jobResult->setContext(new TestContext()); $jobResult->setSuccessful(true); $mocker = $this->jobExecutor->expects($this->exactly(count($expected)))->method('executeJob'); call_user_func_array([$mocker, 'withConsecutive'], $expected); $mocker->willReturn($jobResult); $processor = $this->getSyncProcessor(); $processor->process($this->integration, $data['connector'], $data['parameters']); }
public function testOneIntegrationConnectorProcess() { $connector = 'testConnector'; $this->integration->expects($this->never())->method('getConnectors'); $this->integration->expects($this->once())->method('getId')->will($this->returnValue('testChannel')); $expectedAlias = 'test_alias'; $this->processorRegistry->expects($this->once())->method('getProcessorAliasesByEntity')->with(ProcessorRegistry::TYPE_EXPORT)->will($this->returnValue(array($expectedAlias))); $realConnector = new TestConnector(); $this->registry->expects($this->once())->method('getConnectorType')->will($this->returnValue($realConnector)); $this->integration->expects($this->once())->method('getEnabled')->will($this->returnValue(true)); $jobResult = new JobResult(); $jobResult->setContext(new TestContext()); $jobResult->setSuccessful(true); $this->jobExecutor->expects($this->once())->method('executeJob')->with('export', 'tstJobName', ['export' => ['entityName' => 'testEntity', 'channel' => 'testChannel', 'processorAlias' => $expectedAlias, 'testParameter' => 'testValue']])->will($this->returnValue($jobResult)); $processor = $this->getReverseSyncProcessor(); $processor->process($this->integration, $connector, ['testParameter' => 'testValue']); }
public function testOneChannelConnectorProcess() { $connector = 'testConnector'; $connectors = [$connector]; $this->integration->expects($this->once())->method('getConnectors')->will($this->returnValue($connectors)); $this->integration->expects($this->once())->method('getId')->will($this->returnValue('testChannel')); $this->integration->expects($this->atLeastOnce())->method('getType')->will($this->returnValue('testChannelType')); $this->integration->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); $realConnector = new TestConnector(); $this->registry->expects($this->once())->method('getConnectorType')->will($this->returnValue($realConnector)); $this->processorRegistry->expects($this->once())->method('getProcessorAliasesByEntity')->will($this->returnValue([])); $jobResult = new JobResult(); $jobResult->setContext(new TestContext()); $jobResult->setSuccessful(true); $this->jobExecutor->expects($this->once())->method('executeJob')->with('import', 'test job', ['import' => ['processorAlias' => false, 'entityName' => 'testEntity', 'channel' => 'testChannel', 'channelType' => 'testChannelType', 'testParameter' => 'testValue']])->will($this->returnValue($jobResult)); $processor = $this->getSyncProcessor(); $processor->process($this->integration, $connector, ['testParameter' => 'testValue']); }
public function testFinishView() { $this->registry->expects($this->once())->method('getAvailableIntegrationTypesDetailedData')->will($this->returnValue(['testType1' => ["label" => "oro.type1.label", "icon" => "bundles/acmedemo/img/logo.png"], 'testType2' => ["label" => "oro.type2.label"]])); $this->assetHelper->expects($this->once())->method('getUrl')->will($this->returnArgument(0)); $testIntegration1 = new Integration(); $testIntegration1->setType('testType1'); $testIntegration1Label = uniqid('label'); $testIntegration1Id = uniqid('id'); $testIntegration2 = new Integration(); $testIntegration2->setType('testType2'); $testIntegration2Label = uniqid('label'); $testIntegration2Id = uniqid('id'); $view = new FormView(); $view->vars['choices'] = [new ChoiceView($testIntegration1, $testIntegration1Id, $testIntegration1Label), new ChoiceView($testIntegration2, $testIntegration2Id, $testIntegration2Label)]; $this->type->finishView($view, $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface'), []); $this->assertEquals($testIntegration1Label, $view->vars['choices'][0]->label); $this->assertEquals($testIntegration2Label, $view->vars['choices'][1]->label); $this->assertEquals(['data-status' => true, 'data-icon' => 'bundles/acmedemo/img/logo.png'], $view->vars['choices'][0]->attr); }