Esempio n. 1
0
 /**
  * @covers ::getInfo
  */
 public function testGetInfo()
 {
     $token_info = array('types' => array('foo' => array('name' => $this->randomMachineName())));
     $this->language->expects($this->atLeastOnce())->method('getId')->will($this->returnValue($this->randomMachineName()));
     $this->languageManager->expects($this->once())->method('getCurrentLanguage')->with(LanguageInterface::TYPE_CONTENT)->will($this->returnValue($this->language));
     // The persistent cache must only be hit once, after which the info is
     // cached statically.
     $this->cache->expects($this->once())->method('get');
     $this->cache->expects($this->once())->method('set')->with('token_info:' . $this->language->getId(), $token_info);
     $this->moduleHandler->expects($this->once())->method('invokeAll')->with('token_info')->will($this->returnValue($token_info));
     $this->moduleHandler->expects($this->once())->method('alter')->with('token_info', $token_info);
     // Get the information for the first time. The cache should be checked, the
     // hooks invoked, and the info should be set to the cache should.
     $this->token->getInfo();
     // Get the information for the second time. The data must be returned from
     // the static cache, so the persistent cache must not be accessed and the
     // hooks must not be invoked.
     $this->token->getInfo();
 }
Esempio n. 2
0
 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  */
 public function testGetInfoThrowException()
 {
     $this->_object->setData('info', new \Magento\Framework\Object([]));
     $this->_object->getInfo();
 }
 /**
  * @covers ::getInfo
  */
 public function testGetInfo()
 {
     $info = $this->sut->getInfo();
     $this->assertInternalType('array', $info);
     $this->assertTrue(is_callable($info['#process'][0]));
 }