Skip to content

Commit

Permalink
Mocking in JDocumentRendererHtmlModulesTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Babker committed Jul 18, 2017
1 parent fadc304 commit a783d23
Showing 1 changed file with 20 additions and 1 deletion.
Expand Up @@ -41,11 +41,28 @@ protected function setUp()

$this->saveFactoryState();

JFactory::$application = $this->getMockCmsApp();
$mockApp = $this->getMockCmsApp();
$mockApp->expects($this->any())
->method('getName')
->willReturn('site');

$mockApp->expects($this->any())
->method('isClient')
->with('site')
->willReturn(true);

JFactory::$application = $mockApp;
JFactory::$session = $this->getMockSession();
$this->dispatcher = new JEventDispatcher;
TestReflection::setValue($this->dispatcher, 'instance', $this->dispatcher);
$this->dispatcher->register('onAfterRenderModules', array($this, 'eventCallback'));

$mockRouter = $this->getMockBuilder('Joomla\\CMS\\Router\\Router')->getMock();
$mockRouter->expects($this->any())
->method('build')
->willReturn(new \JUri);

TestReflection::setValue('JRoute', '_router', array('site' => $mockRouter));
}

/**
Expand All @@ -58,6 +75,8 @@ protected function setUp()
*/
protected function tearDown()
{
TestReflection::setValue('JRoute', '_router', array());

$this->restoreFactoryState();
TestReflection::setValue($this->dispatcher, 'instance', null);
parent::tearDown();
Expand Down

0 comments on commit a783d23

Please sign in to comment.