Пример #1
0
 /**
  * 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 a call to JApplicationBase::getDispatcher().
     if (isset($options['dispatcher'])) {
         $mockObject->expects($test->any())->method('getDispatcher')->willReturn($options['dispatcher']);
     } else {
         $mockObject->expects($test->any())->method('getDispatcher')->willReturn(TestMockDispatcher::create($test));
     }
     $test->assignMockReturns($mockObject, array('close' => true));
     return $mockObject;
 }
Пример #2
0
 /**
  * Gets a mock dispatcher object.
  *
  * @param   boolean  $defaults  Add default register and trigger methods for testing.
  *
  * @return  JDispatcher
  *
  * @since   12.1
  */
 public function getMockDispatcher($defaults = true)
 {
     // Attempt to load the real class first.
     class_exists('JDispatcher');
     return TestMockDispatcher::create($this, $defaults);
 }
Пример #3
0
 /**
  * Gets a mock dispatcher object.
  *
  * @param   boolean  $defaults  Add default register and trigger methods for testing.
  *
  * @return  \Joomla\Event\DispatcherInterface
  *
  * @since   12.1
  */
 public function getMockDispatcher($defaults = true)
 {
     // Attempt to load the interface first.
     class_exists('Joomla\\Event\\DispatcherInterface');
     return TestMockDispatcher::create($this, $defaults);
 }