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


PHP PHPUnit_Framework_TestCase::returnValue方法代码示例

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


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

示例1: buildStub

 protected function buildStub($will)
 {
     if (!is_object($will) || !$will instanceof PHPUnit_Framework_MockObject_Stub) {
         $will = $this->testCase->returnValue($this->buildIfValueIsABuilder($will));
     }
     return $will;
 }
开发者ID:schnipseljagd,项目名称:testdatabuilder,代码行数:7,代码来源:StubBuilder.php

示例2: getAuthenticationSubject

 /**
  *
  * @param string $username
  * @return \Nethgui\Authorization\UserInterface
  */
 public static function getAuthenticationSubject(\PHPUnit_Framework_TestCase $testcase, $username = FALSE, $groups = array())
 {
     $subject = $testcase->getMock('Nethgui\\Authorization\\User', array('authenticate', 'isAuthenticated', 'getCredential', 'hasCredential', 'getLanguageCode', 'asAuthorizationString', 'getAuthorizationAttribute'));
     $subject->expects($testcase->any())->method('isAuthenticated')->will($testcase->returnValue(is_string($username)));
     $subject->expects($testcase->any())->method('getCredential')->with('username')->will($testcase->returnValue(is_string($username) ? $username : NULL));
     $subject->expects($testcase->any())->method('hasCredential')->with('username')->will($testcase->returnValue(is_string($username)));
     $getAttribute = function ($attName) use($username, $groups) {
         if ($attName === 'username') {
             return is_string($username) ? $username : NULL;
         } elseif ($attName === 'authenticated') {
             return is_string($username) ? TRUE : FALSE;
         } elseif ($attName == 'groups') {
             return $groups;
         }
         return NULL;
     };
     $subject->expects($testcase->any())->method('getAuthorizationAttribute')->withAnyParameters()->will($testcase->returnCallback($getAttribute));
     $subject->expects($testcase->any())->method('asAuthorizationString')->will($testcase->returnValue(is_string($username) ? $username : 'Anonymous'));
     $subject->hasCredential('username');
     $subject->getCredential('username');
     $subject->isAuthenticated();
     $subject->getAuthorizationAttribute('username');
     $subject->asAuthorizationString();
     return $subject;
 }
开发者ID:SystemEd-Jacob,项目名称:nethgui,代码行数:30,代码来源:MockFactory.php

示例3: create

 /**
  * Create a new mock of the curlbuilder and return
  * the given filename as content
  *
  * @access public
  * @param  PHPUnit_Framework_TestCase   $instance
  * @return mock
  */
 public static function create($instance)
 {
     $reflection = new \ReflectionMethod($instance, $instance->getName());
     $doc_block = $reflection->getDocComment();
     $responsefile = self::parseDocBlock($doc_block, '@responsefile');
     $responsecode = self::parseDocBlock($doc_block, '@responsecode');
     $defaultheaders = array("X-Ratelimit-Limit" => "1000", "X-Ratelimit-Remaining" => "998", "X-Varnish" => "4059929980");
     $skipmock = self::parseDocBlock($doc_block, '@skipmock');
     if (empty($responsecode)) {
         $responsecode = [201];
     }
     if (empty($responsefile)) {
         $responsefile = [$instance->getName()];
     }
     // Setup Curlbuilder mock
     $curlbuilder = $instance->getMockBuilder("\\DirkGroenen\\Pinterest\\Utils\\CurlBuilder")->getMock();
     $curlbuilder->expects($instance->any())->method('create')->will($instance->returnSelf());
     // Build response file path
     $responseFilePath = __DIR__ . '/../responses/' . (new \ReflectionClass($instance))->getShortName() . '/' . $responsefile[0] . ".json";
     if (file_exists($responseFilePath)) {
         $curlbuilder->expects($instance->once())->method('execute')->will($instance->returnValue(file_get_contents($responseFilePath)));
     }
     $curlbuilder->expects($instance->any())->method('getInfo')->will($instance->returnValue($responsecode[0]));
     return $curlbuilder;
 }
开发者ID:veksa,项目名称:Pinterest-API-PHP,代码行数:33,代码来源:CurlBuilderMock.php

示例4: create

 /**
  * Creates an instance of the mock JMenu object.
  *
  * @param   object  $test  A test object.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject
  *
  * @since   3.4
  */
 public static function create(PHPUnit_Framework_TestCase $test)
 {
     $methods = array('getItem', 'setActive', 'getActive', 'getItems');
     // Create the mock.
     $mockObject = $test->getMock('JMenu', $methods, array(), '', false);
     if (count(self::$data) == 0) {
         self::createMenuSampleData();
     }
     $mockObject->expects($test->any())->method('getItem')->will($test->returnValueMap(self::$data));
     $mockObject->expects($test->any())->method('getActive')->will($test->returnValue(self::$data[self::$active]));
     $mockObject->expects($test->any())->method('getItems')->will($test->returnValue(self::$data));
     return $mockObject;
 }
开发者ID:Harmageddon,项目名称:com_monitor,代码行数:22,代码来源:menu.php

示例5: mockAggregate

 /**
  * @param Identifies $id
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 public function mockAggregate(Identifies $id)
 {
     $class = 'SimpleES\\EventSourcing\\Aggregate\\TracksEvents';
     $aggregate = $this->testCase->getMock($class);
     $aggregate->expects($this->testCase->any())->method('aggregateId')->will($this->testCase->returnValue($id));
     return $aggregate;
 }
开发者ID:f500,项目名称:event-sourcing,代码行数:11,代码来源:TestHelper.php

示例6: create

 /**
  * Creates an instance of the mock JMenu object.
  *
  * @param   PHPUnit_Framework_TestCase  $test  A test object.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject
  *
  * @since   3.4
  */
 public static function create(PHPUnit_Framework_TestCase $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;
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:26,代码来源:menu.php

示例7: create

 /**
  * Creates and instance of the mock object.
  *
  * @param   PHPUnit_Framework_TestCase  $test  A test object.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject
  */
 public static function create($test)
 {
     // Collect all the relevant methods in JDatabase.
     $methods = array('getIssueId', 'setIssueId', 'getIssue', 'getIssueProject', 'getIssues');
     // Create the mock.
     $mockObject = $test->getMock('MonitorModelIssue', $methods, array(), '', false);
     self::createSampleData();
     $setterCallback = function ($id) {
         self::$issueId = $id;
     };
     $mockObject->expects($test->any())->method('setIssueId')->will($test->returnCallback($setterCallback));
     $mockObject->expects($test->any())->method('getIssueId')->will($test->returnValue(self::$issueId));
     $mockObject->expects($test->any())->method('getIssue')->will($test->returnValue(self::$data[self::$issueId]));
     $mockObject->expects($test->any())->method('getIssueProject')->will($test->returnValue(1));
     $mockObject->expects($test->any())->method('getIssues')->will($test->returnValue(self::$data));
     return $mockObject;
 }
开发者ID:Harmageddon,项目名称:com_monitor,代码行数:24,代码来源:issue.php

示例8: getLayoutFromFixture

 /**
  * Retrieve new layout model instance with layout updates from a fixture file
  *
  * @param string $layoutUpdatesFile
  * @param array $args
  * @return Mage_Core_Model_Layout|PHPUnit_Framework_MockObject_MockObject
  */
 public function getLayoutFromFixture($layoutUpdatesFile, array $args = array())
 {
     $layout = $this->_testCase->getMock('Mage_Core_Model_Layout', array('getUpdate'), $args);
     $layoutUpdate = $this->getLayoutUpdateFromFixture($layoutUpdatesFile);
     $layoutUpdate->asSimplexml();
     $layout->expects(PHPUnit_Framework_TestCase::any())->method('getUpdate')->will(PHPUnit_Framework_TestCase::returnValue($layoutUpdate));
     return $layout;
 }
开发者ID:nayanchamp,项目名称:magento2,代码行数:15,代码来源:Layout.php

示例9: getLayoutFromFixture

 /**
  * Retrieve new layout model instance with layout updates from a fixture file
  *
  * @param string|array $layoutUpdatesFile
  * @param array $args
  * @return \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject
  */
 public function getLayoutFromFixture($layoutUpdatesFile, array $args = [])
 {
     $layout = $this->_testCase->getMock('Magento\\Framework\\View\\Layout', ['getUpdate'], $args);
     $layoutUpdate = $this->getLayoutUpdateFromFixture($layoutUpdatesFile);
     $layoutUpdate->asSimplexml();
     $layout->expects(\PHPUnit_Framework_TestCase::any())->method('getUpdate')->will(\PHPUnit_Framework_TestCase::returnValue($layoutUpdate));
     return $layout;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:Layout.php

示例10: getCollectionMock

 /**
  * Get collection mock
  *
  * @param string $className
  * @param array $data
  * @return \PHPUnit_Framework_MockObject_MockObject
  * @throws \InvalidArgumentException
  */
 public function getCollectionMock($className, array $data)
 {
     if (!is_subclass_of($className, '\\Magento\\Framework\\Data\\Collection')) {
         throw new \InvalidArgumentException($className . ' does not instance of \\Magento\\Framework\\Data\\Collection');
     }
     $mock = $this->_testObject->getMock($className, [], [], '', false, false);
     $iterator = new \ArrayIterator($data);
     $mock->expects($this->_testObject->any())->method('getIterator')->will($this->_testObject->returnValue($iterator));
     return $mock;
 }
开发者ID:,项目名称:,代码行数:18,代码来源:

示例11: create

 /**
  * Create a new mock of the curlbuilder and return 
  * the given filename as content
  * 
  * @access public
  * @param  PHPUnit_Framework_TestCase   $instance
  * @return mock
  */
 public static function create($instance)
 {
     $reflection = new \ReflectionMethod($instance, $instance->getName());
     $doc_block = $reflection->getDocComment();
     $responsefile = self::parseDocBlock($doc_block, '@responsefile');
     $responsecode = self::parseDocBlock($doc_block, '@responsecode');
     if (empty($responsecode)) {
         $responsecode = [201];
     }
     if (empty($responsefile)) {
         $responsefile = [$instance->getName()];
     }
     // Setup Curlbuilder mock
     $curlbuilder = $instance->getMockBuilder("\\DirkGroenen\\Pinterest\\Utils\\CurlBuilder")->getMock();
     $curlbuilder->expects($instance->once())->method('create')->will($instance->returnSelf());
     $curlbuilder->expects($instance->once())->method('execute')->will($instance->returnValue(file_get_contents(__DIR__ . '/../responses/' . (new \ReflectionClass($instance))->getShortName() . '/' . $responsefile[0] . ".json")));
     $curlbuilder->expects($instance->any())->method('getInfo')->will($instance->returnValue($responsecode[0]));
     return $curlbuilder;
 }
开发者ID:sfai05,项目名称:Pinterest-API-PHP,代码行数:27,代码来源:CurlBuilderMock.php

示例12: SetUpForFunctionalTests

 public static function SetUpForFunctionalTests(\PHPUnit_Framework_TestCase &$test)
 {
     $context = new ApiContext();
     $context->setConfig(array('mode' => 'sandbox', 'http.ConnectionTimeOut' => 30, 'log.LogEnabled' => true, 'log.FileName' => '../PayPal.log', 'log.LogLevel' => 'FINE', 'validation.level' => 'warning'));
     PayPalCredentialManager::getInstance()->setCredentialObject(PayPalCredentialManager::getInstance()->getCredentialObject('acct1'));
     self::$mode = getenv('REST_MODE') ? getenv('REST_MODE') : 'mock';
     if (self::$mode != 'sandbox') {
         // Mock PayPalRest Caller if mode set to mock
         $test->mockPayPalRestCall = $test->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
         $test->mockPayPalRestCall->expects($test->any())->method('execute')->will($test->returnValue($test->response));
     }
 }
开发者ID:johnmicahmiguel,项目名称:yodaphp,代码行数:12,代码来源:Setup.php

示例13: buildMock

 /**
  * Build PHPUnit Mock in this method using $this->config for return values
  * Over-ride this for custom mock building
  *
  * @return \PHPUnit_Framework_MockObject_MockObject
  * @throws \Exception
  */
 public function buildMock()
 {
     if (empty($this->className)) {
         throw new \Exception('Class name is required for default buildMock');
     }
     $config = $this->config;
     $mock = $this->testCase->getMockBuilder($this->className)->disableOriginalConstructor()->getMock();
     foreach ($config as $key => $returnValue) {
         $mock->method($key)->will($this->testCase->returnValue($returnValue));
     }
     return $mock;
 }
开发者ID:jerv13,项目名称:php-unit-mock,代码行数:19,代码来源:Mock.php

示例14: init

 public function init()
 {
     $wikiaAppArgs = array();
     $globalRegistryMock = null;
     $functionWrapperMock = null;
     $globalRegistryMock = $this->testCase->getMock('WikiaGlobalRegistry', array('get', 'set'));
     $globalRegistryMock->expects($this->testCase->any())->method('get')->will($this->testCase->returnCallback(array($this, 'getGlobalCallback')));
     if (in_array('runFunction', $this->methods)) {
         $functionWrapperMock = $this->testCase->getMock('WikiaFunctionWrapper', array_keys($this->mockedFunctions));
         foreach ($this->mockedFunctions as $functionName => $functionData) {
             $functionWrapperMock->expects($this->testCase->exactly($functionData['calls']))->method($functionName)->will($this->testCase->returnValue($functionData['value']));
         }
     }
     $wikiaAppArgs[] = $globalRegistryMock;
     $wikiaAppArgs[] = null;
     // WikiaLocalRegistry
     $wikiaAppArgs[] = null;
     // WikiaHookDispatcher
     $wikiaAppArgs[] = $functionWrapperMock;
     $this->mock = $this->testCase->getMock('WikiaApp', array('ajax'), $wikiaAppArgs, '');
     F::setInstance('App', $this->mock);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:22,代码来源:WikiaAppMock.class.php

示例15: SetUpForFunctionalTests

 public static function SetUpForFunctionalTests(\PHPUnit_Framework_TestCase &$test)
 {
     $configs = array('mode' => 'sandbox', 'http.ConnectionTimeOut' => 30, 'log.LogEnabled' => true, 'log.FileName' => '../PayPal.log', 'log.LogLevel' => 'FINE', 'validation.level' => 'log');
     $test->apiContext = new ApiContext(new OAuthTokenCredential('AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS', 'EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL'));
     $test->apiContext->setConfig($configs);
     //PayPalConfigManager::getInstance()->addConfigFromIni(__DIR__. '/../../../sdk_config.ini');
     //PayPalConfigManager::getInstance()->addConfigs($configs);
     PayPalCredentialManager::getInstance()->setCredentialObject(PayPalCredentialManager::getInstance()->getCredentialObject('acct1'));
     self::$mode = getenv('REST_MODE') ? getenv('REST_MODE') : 'mock';
     if (self::$mode != 'sandbox') {
         // Mock PayPalRest Caller if mode set to mock
         $test->mockPayPalRestCall = $test->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
         $test->mockPayPalRestCall->expects($test->any())->method('execute')->will($test->returnValue($test->response));
     }
 }
开发者ID:Roc4rdho,项目名称:app,代码行数:15,代码来源:Setup.php


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