本文整理汇总了PHP中Mockery::parseShouldReturnArgs方法的典型用法代码示例。如果您正苦于以下问题:PHP Mockery::parseShouldReturnArgs方法的具体用法?PHP Mockery::parseShouldReturnArgs怎么用?PHP Mockery::parseShouldReturnArgs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mockery
的用法示例。
在下文中一共展示了Mockery::parseShouldReturnArgs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shouldReceive
/**
* Set expected method calls
*
* @param mixed
* @return \Mockery\Expectation
*/
public function shouldReceive()
{
/** @var array $nonPublicMethods */
$nonPublicMethods = $this->getNonPublicMethods();
$self = $this;
$allowMockingProtectedMethods = $this->_mockery_allowMockingProtectedMethods;
$lastExpectation = \Mockery::parseShouldReturnArgs($this, func_get_args(), function ($method) use($self, $nonPublicMethods, $allowMockingProtectedMethods) {
$rm = $self->mockery_getMethod($method);
if ($rm) {
if ($rm->isPrivate()) {
throw new \InvalidArgumentException("{$method}() cannot be mocked as it is a private method");
}
if (!$allowMockingProtectedMethods && $rm->isProtected()) {
throw new \InvalidArgumentException("{$method}() cannot be mocked as it a protected method and mocking protected methods is not allowed for this mock");
}
}
$director = $self->mockery_getExpectationsFor($method);
if (!$director) {
$director = new \Mockery\ExpectationDirector($method, $self);
$self->mockery_setExpectationsFor($method, $director);
}
$expectation = new \Mockery\Expectation($self, $method);
$director->addExpectation($expectation);
return $expectation;
});
return $lastExpectation;
}
示例2: shouldReceive
/**
* Set expected method calls
*
* @param mixed
* @return \Mockery\Expectation
*/
public function shouldReceive()
{
$self =& $this;
$lastExpectation = \Mockery::parseShouldReturnArgs($this, func_get_args(), function ($method) use($self) {
$director = $self->mockery_getExpectationsFor($method);
if (!$director) {
$director = new \Mockery\ExpectationDirector($method, $self);
$self->mockery_setExpectationsFor($method, $director);
}
$expectation = new \Mockery\Expectation($self, $method);
$director->addExpectation($expectation);
return $expectation;
});
return $lastExpectation;
}
示例3: shouldReceive
/**
* Set expected method calls
*
* @param string $methodName,... one or many methods that are expected to be called in this mock
* @return \Mockery\Expectation
*/
public function shouldReceive($methodName)
{
if (func_num_args() < 1) {
throw new \InvalidArgumentException("At least one method name is required");
}
foreach (func_get_args() as $method) {
if ("" == $method) {
throw new \InvalidArgumentException("Received empty method name");
}
}
/** @var array $nonPublicMethods */
$nonPublicMethods = $this->getNonPublicMethods();
$self = $this;
$allowMockingProtectedMethods = $this->_mockery_allowMockingProtectedMethods;
$lastExpectation = \Mockery::parseShouldReturnArgs($this, func_get_args(), function ($method) use($self, $nonPublicMethods, $allowMockingProtectedMethods) {
$rm = $self->mockery_getMethod($method);
if ($rm) {
if ($rm->isPrivate()) {
throw new \InvalidArgumentException("{$method}() cannot be mocked as it is a private method");
}
if (!$allowMockingProtectedMethods && $rm->isProtected()) {
throw new \InvalidArgumentException("{$method}() cannot be mocked as it is a protected method and mocking protected methods is not enabled for the currently used mock object.");
}
}
$director = $self->mockery_getExpectationsFor($method);
if (!$director) {
$director = new \Mockery\ExpectationDirector($method, $self);
$self->mockery_setExpectationsFor($method, $director);
}
$expectation = new \Mockery\Expectation($self, $method);
$director->addExpectation($expectation);
return $expectation;
});
return $lastExpectation;
}