Ejemplo n.º 1
0
 /**
  * Set up
  *
  * @return void
  */
 protected function setUp()
 {
     $this->iconRegistryMock = $this->prophesize(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
     $this->subject = new IconFactory($this->iconRegistryMock->reveal());
     $this->iconRegistryMock->isRegistered('tcarecords--default')->willReturn(false);
     $this->iconRegistryMock->isRegistered(Argument::any())->willReturn(true);
     $this->iconRegistryMock->isDeprecated(Argument::any())->willReturn(false);
     $this->iconRegistryMock->getDefaultIconIdentifier(Argument::any())->willReturn('default-not-found');
     $this->iconRegistryMock->getIconIdentifierForMimeType('application/pdf')->willReturn('mimetypes-pdf');
     $this->iconRegistryMock->getIconIdentifierForMimeType('image/*')->willReturn('mimetypes-media-image');
     $this->iconRegistryMock->getIconIdentifierForMimeType(Argument::any())->willReturn(null);
     $this->iconRegistryMock->getIconIdentifierForFileExtension(Argument::any())->willReturn('mimetypes-other-other');
     $this->iconRegistryMock->getIconIdentifierForFileExtension('foo')->willReturn('mimetypes-other-other');
     $this->iconRegistryMock->getIconIdentifierForFileExtension('pdf')->willReturn('mimetypes-pdf');
     $this->iconRegistryMock->getIconIdentifierForFileExtension('png')->willReturn('mimetypes-media-image');
     $this->iconRegistryMock->getIconConfigurationByIdentifier(Argument::any())->willReturn(['provider' => FontawesomeIconProvider::class, 'options' => array('name' => 'times', 'additionalClasses' => 'fa-fw')]);
 }
Ejemplo n.º 2
0
 /**
  * @param string $identifier
  * @param string $size "large", "small" or "default", see the constants of the Icon class
  * @param string $overlayIdentifier
  * @param IconState $state
  * @return Icon
  */
 public function getIcon($identifier, $size = Icon::SIZE_DEFAULT, $overlayIdentifier = null, IconState $state = null)
 {
     if ($this->iconRegistry->isDeprecated($identifier)) {
         $deprecationSettings = $this->iconRegistry->getDeprecationSettings($identifier);
         GeneralUtility::deprecationLog(sprintf($deprecationSettings['message'], $identifier));
         if (!empty($deprecationSettings['replacement'])) {
             $identifier = $deprecationSettings['replacement'];
         }
     }
     if (!$this->iconRegistry->isRegistered($identifier)) {
         $identifier = $this->iconRegistry->getDefaultIconIdentifier();
     }
     $iconConfiguration = $this->iconRegistry->getIconConfigurationByIdentifier($identifier);
     $iconConfiguration['state'] = $state;
     $icon = $this->createIcon($identifier, $size, $overlayIdentifier, $iconConfiguration);
     /** @var IconProviderInterface $iconProvider */
     $iconProvider = GeneralUtility::makeInstance($iconConfiguration['provider']);
     $iconProvider->prepareIconMarkup($icon, $iconConfiguration['options']);
     return $icon;
 }
Ejemplo n.º 3
0
 /**
  * @test
  * @param $deprecationSettings
  * @param $expected
  * @dataProvider getIconReturnsReplacementIconWhenDeprecatedDataProvider
  */
 public function getIconReturnsReplacementIconWhenDeprecated($deprecationSettings, $expected)
 {
     $this->iconRegistryMock->isDeprecated($this->registeredIconIdentifier)->willReturn(true);
     $this->iconRegistryMock->getDeprecationSettings($this->registeredIconIdentifier)->willReturn($deprecationSettings);
     $this->assertContains($expected, $this->subject->getIcon($this->registeredIconIdentifier, Icon::SIZE_SMALL)->render());
 }