Example #1
0
 /**
  * @covers \Magento\Framework\Filter\Template::afterFilter
  * @covers \Magento\Framework\Filter\Template::addAfterFilterCallback
  * @covers \Magento\Framework\Filter\Template::resetAfterFilterCallbacks
  */
 public function testAfterFilterCallbackReset()
 {
     $value = 'test string';
     $expectedResult = 'TEST STRING';
     // Build arbitrary object to pass into the addAfterFilterCallback method
     $callbackObject = $this->getMockBuilder('stdObject')->setMethods(['afterFilterCallbackMethod'])->getMock();
     $callbackObject->expects($this->once())->method('afterFilterCallbackMethod')->with($value)->will($this->returnValue($expectedResult));
     $this->templateFilter->addAfterFilterCallback([$callbackObject, 'afterFilterCallbackMethod']);
     // Callback should run and filter content
     $this->assertEquals($expectedResult, $this->templateFilter->filter($value));
     // Callback should *not* run as callbacks should be reset
     $this->assertEquals($value, $this->templateFilter->filter($value));
 }