/**
  * Test JComponentRouterBase::preprocess
  *
  * @return  void
  *
  * @since   3.4
  * @covers  JComponentRouterBase::preprocess
  */
 public function testPreprocess()
 {
     $app = TestMockApplication::create($this);
     $menu = TestMockMenu::create($this);
     $object = new JComponentRouterBaseInspector($app, $menu);
     $array = array('option' => 'com_test', 'view' => 'test');
     $this->assertEquals($array, $object->preprocess($array));
 }
Exemplo n.º 2
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.4
  */
 protected function setUp()
 {
     parent::setUp();
     JUri::reset();
     $this->server = $_SERVER;
     $_SERVER['HTTP_HOST'] = 'mydomain.com';
     $this->object = new JRouterSite($this->getMockCmsApp(), TestMockMenu::create($this));
 }
 /**
  * Creates and instance of the mock JApplication object.
  *
  * @param   object  $test  A test object.
  *
  * @return  object
  *
  * @since   11.3
  */
 public static function create($test)
 {
     // Collect all the relevant methods in JApplication (work in progress).
     $methods = array('get', 'getCfg', 'getIdentity', 'getRouter', 'getTemplate', 'getMenu', 'getLanguage');
     // Create the mock.
     $mockObject = $test->getMock('JApplication', $methods, array(), '', false);
     $menu = TestMockMenu::create($test);
     $mockObject->expects($test->any())->method('getMenu')->will($test->returnValue($menu));
     $language = TestMockLanguage::create($test);
     $mockObject->expects($test->any())->method('getLanguage')->will($test->returnValue($language));
     $mockObject->input = new JInput();
     return $mockObject;
 }
Exemplo n.º 4
0
 /**
  * Tests the setComponentRouter() method
  *
  * @return  void
  *
  * @since   3.4
  */
 public function testInvalidRouterIsRejected()
 {
     $object = new JRouterSite(array(), $this->getMockCmsApp(), TestMockMenu::create($this));
     $this->assertFalse($object->setComponentRouter('com_test3', new stdClass()));
 }
 /**
  * Adds mock objects for some methods.
  *
  * @param   TestCase                                 $test        A test object.
  * @param   PHPUnit_Framework_MockObject_MockObject  $mockObject  The mock object.
  * @param   array                                    $options     A set of options to configure the mock.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject  The object with the behaviours added
  *
  * @since   3.4
  */
 public static function addBehaviours($test, $mockObject, $options)
 {
     // Mock calls to JApplicationCms::getMenu();
     $mockObject->expects($test->any())->method('getMenu')->will($test->returnValue(TestMockMenu::create($test)));
     return parent::addBehaviours($test, $mockObject, $options);
 }
Exemplo n.º 6
0
 /**
  * Tests the parseSefRoute method
  *
  * @param   string   $url              An associative array with variables
  * @param   integer  $menubool         JROUTER_MODE_RAW or JROUTER_MODE_SEF
  * @param   array    $appConfig        An associative array with app config vars
  * @param   array    $expected         An associative array with $_SERVER vars
  * @param   array    $expectedGlobals  An associative array with $_SERVER vars
  * @param   boolean  $activeMenu       Flag if the item is the active menu
  *
  * @return  void
  *
  * @dataProvider  casesParseSefRoute
  * @since         3.4
  */
 public function testParseSefRoute($url, $menubool, $appConfig, $expected, $expectedGlobals, $activeMenu = false)
 {
     $uri = new JUri($url);
     $app = $this->object->getApp();
     if (isset($expected['Itemid'])) {
         $app->input->set('Itemid', $expected['Itemid']);
     }
     if (isset($appConfig['languagefilter'])) {
         $app->expects($this->any())->method('getLanguageFilter')->will($this->returnValue(true));
         unset($appConfig['languagefilter']);
     }
     $app->expects($this->any())->method('get')->will($this->returnValueMap($appConfig));
     $this->object->setApp($app);
     if ($menubool) {
         $menu = TestMockMenu::create($this, false, $activeMenu);
         $menu->expects($this->any())->method('getDefault')->will($this->returnValue(null));
         $this->object->setMenu($menu);
     } else {
         $menu = TestMockMenu::create($this, true, $activeMenu);
         $this->object->setMenu($menu);
     }
     // The method should return an array of variables
     $vars = $this->object->runParseSefRoute($uri);
     $this->assertEquals($expected, $vars);
     $this->assertEquals($expectedGlobals, $this->object->getVars(), 'global vars');
 }