Esempio n. 1
0
 public function testGetFontUrlWithMultipleFonts()
 {
     $fontCollection = new FontCollection();
     $font1 = $this->getMockBuilder('Cmfcmf\\Module\\MediaModule\\Font\\FontInterface')->getMock();
     $font1->expects($this->any())->method('getId')->willReturn('font1');
     $font1->expects($this->any())->method('getGoogleFontName')->willReturn('font_1');
     $font1->expects($this->any())->method('getTitle')->willReturn('font1');
     $font2 = $this->getMockBuilder('Cmfcmf\\Module\\MediaModule\\Font\\FontInterface')->getMock();
     $font2->expects($this->any())->method('getId')->willReturn('font2');
     $font2->expects($this->any())->method('getGoogleFontName')->willReturn(null);
     $font2->expects($this->any())->method('getTitle')->willReturn('fontTitle');
     $font3 = $this->getMockBuilder('Cmfcmf\\Module\\MediaModule\\Font\\FontInterface')->getMock();
     $font3->expects($this->any())->method('getId')->willReturn('font3');
     $font3->expects($this->any())->method('getGoogleFontName')->willReturn('font3');
     $font3->expects($this->any())->method('getTitle')->willReturn('font3');
     $fontLoader = $this->getMockBuilder('Cmfcmf\\Module\\MediaModule\\Font\\FontLoaderInterface')->getMock();
     $fontLoader->expects($this->once())->method('loadFonts')->willReturn([$font1, $font2, $font3]);
     $fontCollection->addFontLoader($fontLoader);
     $this->assertEquals('https://fonts.googleapis.com/css?family=font+1|font3|', $fontCollection->getFontUrl());
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     parent::buildView($view, $form, $options);
     $view->vars['fontUrl'] = $this->fontCollection->getFontUrl();
 }