/**
  * Checks if the aliases for form types and their names are equal.
  *
  * Form types cannot be used if this is not the case.
  *
  * @param TaggedService|null $service
  * @dataProvider getFormTypes
  */
 public function testFormTypeAliasAndNameAreEqual(TaggedService $service = null)
 {
     if ($service === null) {
         // No form types registered, nothing to test.
         return;
     }
     $creator = new ServiceCreator($this->getContainer());
     /* @var $type \Symfony\Component\Form\FormTypeInterface */
     $type = $creator->create($service->getServiceId());
     $message = 'Service "%s" is tagged as form type, but it does not implement the required interface.';
     $message = sprintf($message, $service->getServiceId());
     $this->assertInstanceOf('\\Symfony\\Component\\Form\\FormTypeInterface', $type, $message);
     $tagDefinition = $service->getTagDefinition();
     $message = 'An alias must be defined for form type "%s".';
     $message = sprintf($message, $service->getServiceId());
     $this->assertArrayHasKey('alias', $service->getTagDefinition(), $message);
     $message = 'Form type name and assigned alias must match, but service "%s" ' . 'uses "%s" as name and "%s" as alias.';
     $message = sprintf($message, $service->getServiceId(), $type->getName(), $tagDefinition['alias']);
     $this->assertEquals($type->getName(), $tagDefinition['alias'], $message);
 }
 /**
  * Checks if the validators that are configured in the container are aliased in Symfony Versions < 2.7.
  *
  * @param TaggedService $service
  * @dataProvider getValidators
  */
 public function testRegisteredValidatorsAreAliasedInOlderSymfonyVersions(TaggedService $service = null)
 {
     if ($service === null) {
         // No validators registered, nothing to test.
         return;
     }
     if (defined('Symfony\\Component\\HttpKernel\\Kernel::VERSION') && version_compare(Kernel::VERSION, '2.7', '>=')) {
         // As of Symfony 2.7, validator services don't need to be aliased in every case.
         return;
     }
     $tagDefinition = $service->getTagDefinition();
     $message = 'An alias must be defined for validation service "%s".';
     $message = sprintf($message, $service->getServiceId());
     $this->assertArrayHasKey('alias', $tagDefinition, $message);
 }