Exemplo n.º 1
0
 /**
  * Creates and instance of the mock JApplicationCli object.
  *
  * @param   FOFTestCase  $test     A test object.
  * @param   array     $options  A set of options to configure the mock.
  *
  * @return  \PHPUnit_Framework_MockObject_MockObject
  *
  * @since   12.2
  */
 public static function create($test, $options = array())
 {
     // Collect all the relevant methods in JApplicationCli.
     $methods = self::getMethods();
     // Create the mock.
     $mockObject = $test->getMock('\\JApplicationCli', $methods, array(), '', true);
     $mockObject = self::addBehaviours($test, $mockObject, $options);
     return $mockObject;
 }
Exemplo n.º 2
0
 /**
  * Creates and instance of the mock JLanguage object.
  *
  * @param   FOFTestCase $test A test object.
  *
  * @return  \PHPUnit_Framework_MockObject_MockObject
  *
  * @since   11.3
  */
 public static function create($test)
 {
     // Collect all the relevant methods in JDatabase.
     $methods = array('parse', 'render', 'test');
     // Create the mock.
     $mockObject = $test->getMock('\\JDocument', $methods, array(), '', false);
     // Mock selected methods.
     $test->assignMockReturns($mockObject, array('parse' => $mockObject, 'test' => 'ok'));
     return $mockObject;
 }
Exemplo n.º 3
0
 /**
  * Creates and instance of the mock JLanguage object.
  *
  * @param   FOFTestCase $test A test object.
  *
  * @return  \PHPUnit_Framework_MockObject_MockObject
  *
  * @since   11.3
  */
 public static function create($test)
 {
     // Collect all the relevant methods in JDatabase.
     $methods = static::getMethods();
     // Create the mock.
     $mockObject = $test->getMock('\\JLanguage', $methods, array(), '', false);
     // Mock selected methods.
     $test->assignMockReturns($mockObject, array('getInstance' => $mockObject, 'getTag' => 'en-GB', 'test' => 'ok'));
     $test->assignMockCallbacks($mockObject, array('_' => array(get_called_class(), 'mock_'), 'load' => array(get_called_class(), 'mockload')));
     return $mockObject;
 }
Exemplo n.º 4
0
 /**
  * Creates and instance of the mock JApplicationBase object.
  *
  * @param   FOFTestCase $test    A test object.
  * @param   array       $options A set of options to configure the mock.
  *
  * @return  \PHPUnit_Framework_MockObject_MockObject
  *
  * @since   11.3
  */
 public static function create($test, $options = array())
 {
     // Set expected server variables.
     if (!isset($_SERVER['HTTP_HOST'])) {
         $_SERVER['HTTP_HOST'] = 'localhost';
     }
     // Collect all the relevant methods in JApplicationBase.
     $methods = self::getMethods();
     // Create the mock.
     $mockObject = $test->getMock('\\JApplicationBase', $methods, array(), '', true);
     $mockObject = self::addBehaviours($test, $mockObject, $options);
     return $mockObject;
 }
Exemplo n.º 5
0
 /**
  * Creates and instance of the mock JApplicationCms object.
  *
  * The test can implement the following overrides:
  * - mockAppendBody
  * - mockGetBody
  * - mockPrepentBody
  * - mockSetBody
  *
  * If any *Body methods are implemented in the test class, all should be implemented otherwise behaviour will be unreliable.
  *
  * @param   FOFTestCase  $test         A test object.
  * @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
  *
  * @since   3.2
  */
 public static function create($test, $options = array(), $constructor = array())
 {
     // Set expected server variables.
     if (!isset($_SERVER['HTTP_HOST'])) {
         $_SERVER['HTTP_HOST'] = 'localhost';
     }
     $methods = self::getMethods();
     if (isset($options)) {
         // Create the mock.
         $mockObject = $test->getMock('\\JApplicationCms', $methods, $constructor, '', true);
     }
     $mockObject = self::addBehaviours($test, $mockObject, $options);
     return $mockObject;
 }
Exemplo n.º 6
0
 /**
  * Creates an instance of the mock JSession object.
  *
  * @param   FOFTestCase  $test     A test object.
  * @param   array                       $options  An array of optional configuration values.
  *                                                getId : the value to be returned by the mock getId method
  *                                                get.user.id : the value to assign to the user object id returned by get('user')
  *                                                get.user.name : the value to assign to the user object name returned by get('user')
  *                                                get.user.username : the value to assign to the user object username returned by get('user')
  *
  * @return  \PHPUnit_Framework_MockObject_MockObject
  *
  * @since   11.3
  */
 public static function create($test, $options = array())
 {
     if (is_array($options)) {
         self::$options = $options;
     }
     // Mock all the public methods.
     $methods = array('clear', 'close', 'destroy', 'fork', 'get', 'getExpire', 'getFormToken', 'getId', 'getInstance', 'getName', 'getState', 'getStores', 'getToken', 'has', 'hasToken', 'getPrefix', 'isNew', 'restart', 'set');
     // Create the mock.
     $mockObject = $test->getMock('\\JSession', $methods, array(), '', false);
     // Mock selected methods.
     $test->assignMockReturns($mockObject, array('getId' => self::getOption('getId')));
     $test->assignMockCallbacks($mockObject, array('get' => array(get_called_class(), 'mockGet')));
     return $mockObject;
 }
Exemplo n.º 7
0
 /**
  * Creates an instance of the mock JMenu object.
  *
  * @param   FOFTestCase  $test  A test object.
  *
  * @return  \PHPUnit_Framework_MockObject_MockObject
  *
  * @since   3.4
  */
 public static function create(FOFTestCase $test, $setDefault = true, $setActive = false)
 {
     // Collect all the relevant methods in JMenu (work in progress).
     $methods = array('getItem', 'setDefault', 'getDefault', 'setActive', 'getActive', 'getItems', 'getParams', 'getMenu', 'authorise', 'load');
     // Create the mock.
     $mockObject = $test->getMock('\\JMenu', $methods, array(), '', false);
     self::createMenuSampleData();
     $mockObject->expects($test->any())->method('getItem')->will($test->returnValueMap(self::prepareGetItemData()));
     $mockObject->expects($test->any())->method('getMenu')->will($test->returnValue(self::$data));
     if ($setDefault) {
         $mockObject->expects($test->any())->method('getDefault')->will($test->returnValueMap(self::prepareDefaultData()));
     }
     if ($setActive) {
         $mockObject->expects($test->any())->method('getActive')->will($test->returnValue(self::$data[$setActive]));
     }
     return $mockObject;
 }