当前位置: 首页>>代码示例>>PHP>>正文


PHP TestCase::getMock方法代码示例

本文整理汇总了PHP中TestCase::getMock方法的典型用法代码示例。如果您正苦于以下问题:PHP TestCase::getMock方法的具体用法?PHP TestCase::getMock怎么用?PHP TestCase::getMock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestCase的用法示例。


在下文中一共展示了TestCase::getMock方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * Creates and instance of the mock WebServiceApplicationWeb 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   TestCase  $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 WebServiceApplicationWeb (work in progress).
     $methods = array('allowCache', 'appendBody', 'clearHeaders', 'close', 'execute', 'get', 'getBody', 'getDocument', 'getHeaders', 'getIdentity', 'getLanguage', 'getSession', 'loadConfiguration', 'loadDispatcher', 'loadDocument', 'loadIdentity', 'loadLanguage', 'loadSession', 'prependBody', 'redirect', 'registerEvent', 'sendHeaders', 'set', 'setBody', 'setHeader', 'triggerEvent');
     // Create the mock.
     $mockObject = $test->getMock('WebServiceApplicationWeb', $methods, array(), '', true);
     // Mock calls to JApplicationWeb::getDocument().
     $mockObject->expects($test->any())->method('getDocument')->will($test->returnValue(TestMockDocument::create($test)));
     // Mock calls to JApplicationWeb::getLanguage().
     $mockObject->expects($test->any())->method('getLanguage')->will($test->returnValue(TestMockLanguage::create($test)));
     // Mock a call to JApplicationWeb::getSession().
     if (isset($options['session'])) {
         $mockObject->expects($test->any())->method('getSession')->will($test->returnValue($options['session']));
     } else {
         $mockObject->expects($test->any())->method('getSession')->will($test->returnValue(TestMockSession::create($test)));
     }
     $test->assignMockCallbacks($mockObject, array('appendBody' => array(is_callable(array($test, 'mockAppendBody')) ? $test : get_called_class(), 'mockAppendBody'), 'getBody' => array(is_callable(array($test, 'mockGetBody')) ? $test : get_called_class(), 'mockGetBody'), 'prependBody' => array(is_callable(array($test, 'mockPrependBody')) ? $test : get_called_class(), 'mockPrependBody'), 'setBody' => array(is_callable(array($test, 'mockSetBody')) ? $test : get_called_class(), 'mockSetBody')));
     // Reset the body storage.
     self::$body = array();
     return $mockObject;
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:43,代码来源:web.php

示例2: create

	/**
	 * Creates and instance of the mock JApplication object.
	 *
	 * @param   TestCase  $test  A test object.
	 * @param   array     $data  Data to prime the cache with.
	 *
	 * @return  object
	 *
	 * @since   12.1
	 */
	public static function create(TestCase $test, $data = array())
	{
		self::$cache = $data;

		// Collect all the relevant methods in JConfig.
		$methods = array(
			'get',
			'store',
		);

		// Create the mock.
		$mockObject = $test->getMock(
			'JCache',
			$methods,
			// Constructor arguments.
			array(),
			// Mock class name.
			'',
			// Call original constructor.
			false
		);

		$test->assignMockCallbacks(
			$mockObject,
			array(
				'get' => array(get_called_class(), 'mockGet'),
				'store' => array(get_called_class(), 'mockStore'),
			)
		);

		return $mockObject;
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:42,代码来源:cache.php

示例3: create

	/**
	 * Creates and instance of the mock JApplicationCli object.
	 *
	 * @param   TestCase  $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 = array(
			'get',
			'execute',
			'loadConfiguration',
			'out',
			'in',
			'set',
		);

		// Create the mock.
		$mockObject = $test->getMock(
			'JApplicationCli',
			$methods,
			// Constructor arguments.
			array(),
			// Mock class name.
			'',
			// Call original constructor.
			true
		);

		return $mockObject;
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:36,代码来源:cli.php

示例4: create

 /**
  * Creates and instance of the mock JApplicationCli object.
  *
  * @param   TestCase  $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 = array('get', 'execute', 'loadConfiguration', 'out', 'in', 'set');
     // Create the mock.
     $mockObject = $test->getMock('JApplicationCli', $methods, array(), '', true);
     return $mockObject;
 }
开发者ID:ZerGabriel,项目名称:joomla-platform,代码行数:18,代码来源:cli.php

示例5: create

 /**
  * Creates and instance of the mock JApplicationCli object.
  *
  * @param   TestCase  $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;
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:19,代码来源:cli.php

示例6: create

 /**
  * Creates and instance of the mock JApplication object.
  *
  * @param   TestCase  $test  A test object.
  * @param   array     $data  Data to prime the cache with.
  *
  * @return  object
  *
  * @since   12.1
  */
 public static function create(TestCase $test, $data = array())
 {
     self::$cache = $data;
     // Collect all the relevant methods in JConfig.
     $methods = array('get', 'store');
     // Create the mock.
     $mockObject = $test->getMock('JCache', $methods, array(), '', false);
     $test->assignMockCallbacks($mockObject, array('get' => array(get_called_class(), 'mockGet'), 'store' => array(get_called_class(), 'mockStore')));
     return $mockObject;
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:20,代码来源:cache.php

示例7: create

 /**
  * 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   TestCase  $test     A test object.
  * @param   array     $options  A set of options to configure the mock.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject
  *
  * @since   3.2
  */
 public static function create($test, $options = array())
 {
     // Set expected server variables.
     if (!isset($_SERVER['HTTP_HOST'])) {
         $_SERVER['HTTP_HOST'] = 'localhost';
     }
     $methods = self::getMethods();
     // Create the mock.
     $mockObject = $test->getMock('JApplicationCms', $methods, array(), '', true);
     $mockObject = self::addBehaviours($test, $mockObject, $options);
     return $mockObject;
 }
开发者ID:akirsoft,项目名称:joomla-cms,代码行数:30,代码来源:cms.php


注:本文中的TestCase::getMock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。