/**
  * @covers ::getDerivativeDefinitions
  */
 function testGetDerivativeDefinitions()
 {
     $string_translation = $this->getStringTranslationStub();
     $class_resolver = $this->getMock(ClassResolverInterface::class);
     $plugin_manager = $this->getMock(PluginManagerInterface::class);
     $provider = $this->randomMachineName();
     $plugin_type_id_a = $this->randomMachineName();
     $plugin_type_label_a = $this->randomMachineName();
     $plugin_type_description_a = $this->randomMachineName();
     $plugin_type_definition_a = ['id' => $plugin_type_id_a, 'label' => $plugin_type_label_a, 'description' => $plugin_type_description_a, 'provider' => $this->randomMachineName()];
     $plugin_type_a = new PluginType($plugin_type_definition_a, $string_translation, $class_resolver, $plugin_manager);
     $plugin_type_id_b = $this->randomMachineName();
     $plugin_type_label_b = $this->randomMachineName();
     $plugin_type_description_b = '';
     $plugin_type_definition_b = ['id' => $plugin_type_id_b, 'label' => $plugin_type_label_b, 'description' => $plugin_type_description_b, 'provider' => $this->randomMachineName()];
     $plugin_type_b = new PluginType($plugin_type_definition_b, $string_translation, $class_resolver, $plugin_manager);
     $plugin_types = [$plugin_type_a, $plugin_type_b];
     $this->pluginTypeManager->expects($this->atLeastOnce())->method('getPluginTypes')->willReturn($plugin_types);
     $base_plugin_definition = ['provider' => $provider];
     $derivative_definitions = $this->sut->getDerivativeDefinitions($base_plugin_definition);
     $this->assertSame($plugin_type_label_a, (string) $derivative_definitions[$plugin_type_id_a]['label']);
     $this->assertSame($plugin_type_description_a, (string) $derivative_definitions[$plugin_type_id_a]['description']);
     $this->assertSame($provider, $derivative_definitions[$plugin_type_id_a]['provider']);
     $this->assertSame($plugin_type_id_a, $derivative_definitions[$plugin_type_id_a]['plugin_type_id']);
     $this->assertSame($plugin_type_label_b, (string) $derivative_definitions[$plugin_type_id_b]['label']);
     $this->assertSame($plugin_type_description_b, (string) $derivative_definitions[$plugin_type_id_b]['description']);
     $this->assertSame($provider, $derivative_definitions[$plugin_type_id_b]['provider']);
     $this->assertSame($plugin_type_id_b, $derivative_definitions[$plugin_type_id_b]['plugin_type_id']);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->paymentStatusManager = $this->getMock(PaymentStatusManagerInterface::class);
     $this->paymentStatusStorage = $this->getMock(EntityStorageInterface::class);
     $this->paymentStatus = $this->getMock(PaymentStatusInterface::class);
     $this->pluginSelectorManager = $this->getMock(PluginSelectorManagerInterface::class);
     $class_resolver = $this->getMock(ClassResolverInterface::class);
     $this->stringTranslation = $this->getStringTranslationStub();
     $this->pluginTypeManager = $this->getMock(PluginTypeManagerInterface::class);
     $plugin_type_definition = ['id' => $this->randomMachineName(), 'label' => $this->randomMachineName(), 'provider' => $this->randomMachineName()];
     $plugin_type = new PluginType($plugin_type_definition, $this->stringTranslation, $class_resolver, $this->paymentStatusManager);
     $this->pluginTypeManager->expects($this->any())->method('getPluginType')->with('payment_status')->willReturn($plugin_type);
     $this->sut = new PaymentStatusForm($this->stringTranslation, $this->paymentStatusStorage, $this->pluginSelectorManager, $this->pluginTypeManager);
     $this->sut->setEntity($this->paymentStatus);
 }
コード例 #3
0
 /**
  * @covers ::execute
  */
 public function testExecute()
 {
     $plugin_manager = $this->getMock(PluginManagerInterface::class);
     $plugin_definition_id_a = $this->randomMachineName();
     $plugin_definition_label_a = $this->randomMachineName();
     $plugin_definition_a = $this->getMock(PluginLabelDefinitionInterface::class);
     $plugin_definition_a->expects($this->atLeastOnce())->method('getId')->willReturn($plugin_definition_id_a);
     $plugin_definition_a->expects($this->atLeastOnce())->method('getLabel')->willReturn($plugin_definition_label_a);
     $plugin_definition_id_b = $this->randomMachineName();
     $plugin_definition_description_b = $this->randomMachineName();
     $plugin_definition_b = $this->getMock(PluginDescriptionDefinitionInterface::class);
     $plugin_definition_b->expects($this->atLeastOnce())->method('getId')->willReturn($plugin_definition_id_b);
     $plugin_definition_b->expects($this->atLeastOnce())->method('getDescription')->willReturn($plugin_definition_description_b);
     $plugin_definitions = [$plugin_definition_id_a => $plugin_definition_a, $plugin_definition_id_b => $plugin_definition_b];
     $plugin_manager->expects($this->atLeastOnce())->method('getDefinitions')->willReturn($plugin_definitions);
     $plugin_type_id = $this->randomMachineName();
     $plugin_type = $this->getMock(PluginTypeInterface::class);
     $plugin_type->expects($this->atLeastOnce())->method('ensureTypedPluginDefinition')->willReturnArgument(0);
     $plugin_type->expects($this->atLeastOnce())->method('getPluginManager')->willReturn($plugin_manager);
     $this->pluginTypeManager->expects($this->atLeastOnce())->method('getPluginType')->with($plugin_type_id)->willReturn($plugin_type);
     $this->pluginTypeManager->expects($this->atLeastOnce())->method('hasPluginType')->with($plugin_type_id)->willReturn(TRUE);
     $build = $this->sut->execute($plugin_type_id);
     $this->assertSame($plugin_definition_label_a, (string) $build[$plugin_definition_id_a]['label']['#markup']);
     $this->assertNull($build[$plugin_definition_id_a]['description']['#markup']);
     $this->assertSame($plugin_definition_id_b, (string) $build[$plugin_definition_id_b]['label']['#markup']);
     $this->assertSame($plugin_definition_description_b, (string) $build[$plugin_definition_id_b]['description']['#markup']);
 }
コード例 #4
0
 /**
  * @covers ::execute
  */
 public function testExecute()
 {
     $class_resolver = $this->getMock(ClassResolverInterface::class);
     $plugin_manager = $this->getMock(PluginManagerInterface::class);
     $plugin_type_id_a = $this->randomMachineName();
     $plugin_type_label_a = $this->randomMachineName();
     $plugin_type_description_a = $this->randomMachineName();
     $plugin_type_definition_a = ['id' => $plugin_type_id_a, 'label' => $plugin_type_label_a, 'description' => $plugin_type_description_a, 'provider' => $this->randomMachineName()];
     $plugin_type_a = new PluginType($plugin_type_definition_a, $this->stringTranslation, $class_resolver, $plugin_manager);
     $plugin_type_id_b = $this->randomMachineName();
     $plugin_type_label_b = $this->randomMachineName();
     $plugin_type_description_b = '';
     $plugin_type_definition_b = ['id' => $plugin_type_id_b, 'label' => $plugin_type_label_b, 'description' => $plugin_type_description_b, 'provider' => $this->randomMachineName()];
     $plugin_type_b = new PluginType($plugin_type_definition_b, $this->stringTranslation, $class_resolver, $plugin_manager);
     $plugin_types = [$plugin_type_id_a => $plugin_type_a, $plugin_type_id_b => $plugin_type_b];
     $this->pluginTypeManager->expects($this->atLeastOnce())->method('getPluginTypes')->willReturn($plugin_types);
     $build = $this->sut->execute();
     $this->assertSame((string) $build[$plugin_type_id_a]['label']['#markup'], $plugin_type_label_a);
     $this->assertSame((string) $build[$plugin_type_id_a]['description']['#markup'], $plugin_type_description_a);
     $this->assertSame((string) $build[$plugin_type_id_b]['label']['#markup'], $plugin_type_label_b);
     $this->assertSame((string) $build[$plugin_type_id_b]['description']['#markup'], $plugin_type_description_b);
 }