/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void * * @since 3.1 */ protected function setUp() { // Ensure the loaded states are reset JHtmlBehaviorInspector::resetLoaded(); $this->saveFactoryState(); JFactory::$application = $this->getMockApplication(); JFactory::$document = $this->getMockDocument(); $this->backupServer = $_SERVER; $_SERVER['HTTP_HOST'] = 'example.com'; $_SERVER['SCRIPT_NAME'] = ''; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void * * @since 3.1 */ protected function setUp() { // Ensure the loaded states are reset JHtmlBehaviorInspector::resetLoaded(); parent::setUp(); $this->saveFactoryState(); JFactory::$application = $this->getMockCmsApp(); JFactory::$document = $this->getMockDocument(); JFactory::$session = $this->getMockSession(); // We generate a random template name so that we don't collide or hit anything JFactory::$application->expects($this->any())->method('getTemplate')->willReturn('mytemplate' . mt_rand(1, 10000)); $this->backupServer = $_SERVER; $_SERVER['HTTP_HOST'] = 'example.com'; $_SERVER['SCRIPT_NAME'] = ''; }
/** * testNoFrames(). * * @return void * * @since 11.3 */ public function testNoFrames() { // we generate a random template name so that we don't collide or hit anything// $template = 'mytemplate' . rand(1, 10000); // we create a stub (not a mock because we don't enforce whether it is called or not) // to return a value from getTemplate $mock = $this->getMock('myMockObject', array('getTemplate')); $mock->expects($this->any())->method('getTemplate')->will($this->returnValue($template)); // @todo We need to mock this. $mock->input = new JInput(); JFactory::$application = $mock; JHtmlBehaviorInspector::resetLoaded(); JHtmlBehaviorInspector::noframes(); $this->assertEquals(array('JHtmlBehavior::noframes' => true, 'JHtmlBehavior::framework' => array('core' => true)), JHtmlBehaviorInspector::getLoaded()); }