Skip to content

Commit

Permalink
Mocking in JFormFieldRulesTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Babker committed Jul 18, 2017
1 parent a783d23 commit fdfa09b
Showing 1 changed file with 21 additions and 1 deletion.
Expand Up @@ -29,8 +29,26 @@ 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();

$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 @@ -41,6 +59,8 @@ protected function setUp()
*/
protected function tearDown()
{
TestReflection::setValue('JRoute', '_router', array());

$this->restoreFactoryState();

parent::tearDown();
Expand Down

0 comments on commit fdfa09b

Please sign in to comment.