示例#1
0
 /**
  * Initializes the page.
  *
  * @param Page $page Page to initialize.
  *
  * @return self
  */
 public function initPage(Page $page)
 {
     /* @var $annotations PageUrlAnnotation[] */
     $annotations = $this->annotationManager->getClassAnnotations($page, '@page-url');
     if (!$annotations || !$annotations[0] instanceof PageUrlAnnotation) {
         return $this;
     }
     $page->setUrlBuilder($this->urlFactory->getBuilder($this->urlNormalizer->normalize($annotations[0])));
     return $this;
 }
 /**
  * @dataProvider initPageDataProvider
  */
 public function testInitPage($url, array $params, $secure, $use_url_builder)
 {
     $url_components = parse_url($url);
     $annotations = $this->expectPageUrlAnnotation($url, $params, $secure);
     /* @var $page Page */
     $page = m::mock($this->pageClass);
     $url_builder = m::mock(self::URL_BUILDER_INTERFACE);
     /** @var Normalizer $url_normalizer */
     $url_normalizer = m::mock(self::URL_NORMALIZER_CLASS);
     $this->realFactory->setUrlFactory($this->urlFactory);
     $this->realFactory->setUrlNormalizer($url_normalizer);
     $url_normalizer->shouldReceive('normalize')->with(reset($annotations))->times(isset($url) ? 1 : 0)->andReturn($url_components);
     $this->urlFactory->shouldReceive('getBuilder')->with($url_components)->times(isset($url) ? 1 : 0)->andReturn($url_builder);
     $page->shouldReceive('setUrlBuilder')->times($use_url_builder ? 1 : 0)->andReturn($page);
     $this->assertSame($this->realFactory, $this->realFactory->initPage($page));
 }