Skip to content

Commit

Permalink
Expand mocking in JHtmlBehaviorTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Babker committed Jul 18, 2017
1 parent 1b233d5 commit 0686d07
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/unit/core/case/case.php
Expand Up @@ -173,7 +173,7 @@ class_exists('JApplication');
* @param array $options A set of options to configure the mock.
* @param array $constructor An array containing constructor arguments to inject into the mock.
*
* @return JApplicationCms
* @return JApplicationCms|PHPUnit_Framework_MockObject_MockObject
*
* @since 3.2
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/core/mock/application/cms.php
Expand Up @@ -26,6 +26,7 @@ public static function getMethods()
// Collect all the relevant methods in JApplicationCms (work in progress).
$methods = array(
'getMenu',
'getName',
'getPathway',
'getTemplate',
'getLanguageFilter',
Expand Down Expand Up @@ -75,7 +76,7 @@ public static function addBehaviours($test, $mockObject, $options)
* @param array $options A set of options to configure the mock.
* @param array $constructor An array containing constructor arguments to inject into the mock.
*
* @return PHPUnit_Framework_MockObject_MockObject
* @return JApplicationCms|PHPUnit_Framework_MockObject_MockObject
*
* @since 3.2
*/
Expand Down
21 changes: 20 additions & 1 deletion tests/unit/suites/libraries/cms/html/JHtmlBehaviorTest.php
Expand Up @@ -43,7 +43,17 @@ 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::$document = $this->getMockDocument();
JFactory::$session = $this->getMockSession();

Expand All @@ -56,6 +66,13 @@ protected function setUp()

$_SERVER['HTTP_HOST'] = 'example.com';
$_SERVER['SCRIPT_NAME'] = '';

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

$_SERVER = $this->backupServer;
unset($this->backupServer);
$this->restoreFactoryState();
Expand Down

0 comments on commit 0686d07

Please sign in to comment.