本文整理汇总了PHP中PHPUnit_Framework_TestCase::any方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestCase::any方法的具体用法?PHP PHPUnit_Framework_TestCase::any怎么用?PHP PHPUnit_Framework_TestCase::any使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_TestCase
的用法示例。
在下文中一共展示了PHPUnit_Framework_TestCase::any方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCronDispatcherTestMock
/**
* @param $isDue
* @return \Trovit\CronManagerBundle\Model\CronExpressionWrapper|\PHPUnit_Framework_MockObject_MockObject
*/
public function getCronDispatcherTestMock($isDue)
{
$mock = $this->getBasicMock();
$cronExpressionMocks = new CronExpressionMocks($this->_testCase);
$mock->expects($this->_testCase->any())->method('createCronExpression')->willReturn($cronExpressionMocks->getCronDispatcherTestMock($isDue));
return $mock;
}
示例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;
}
示例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;
}
示例4: loadMethodStubs
/**
* @param PHPUnit_Framework_MockObject_MockObject $stub
*/
protected function loadMethodStubs($stub)
{
foreach ($this->fields as $field => $will) {
$will = $this->buildStub($will);
$methodConstraint = new TestDataBuilder_SimpleEqualsConstraint($field);
$stub->expects($this->testCase->any())->method($methodConstraint)->will($will);
}
}
示例5: __construct
/**
* @param \PHPUnit_Framework_TestCase $testCase
*
* @param array $classes
*/
public function __construct(\PHPUnit_Framework_TestCase $testCase, array $classes = [])
{
$configProvider = $testCase->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock();
$entityClassResolver = $testCase->getMockBuilder('Oro\\Bundle\\EntityBundle\\ORM\\EntityClassResolver')->disableOriginalConstructor()->getMock();
$entityClassResolver->expects($testCase->any())->method('getEntityClass')->willReturnArgument(0);
$container = $testCase->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
$container->expects($testCase->any())->method('get')->will($testCase->returnValueMap([['oro_entity_config.provider.ownership', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $configProvider], ['oro_entity.orm.entity_class_resolver', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $entityClassResolver]]));
parent::__construct(array_merge(['organization' => 'Oro\\Bundle\\SecurityBundle\\Tests\\Unit\\Acl\\Domain\\Fixtures\\Entity\\Organization', 'business_unit' => 'Oro\\Bundle\\SecurityBundle\\Tests\\Unit\\Acl\\Domain\\Fixtures\\Entity\\BusinessUnit', 'user' => 'Oro\\Bundle\\SecurityBundle\\Tests\\Unit\\Acl\\Domain\\Fixtures\\Entity\\User'], $classes));
$this->setContainer($container);
}
示例6: 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;
}
示例7: fromFixture
/**
* @param string $path
* @param TestCase $testCase
* @return RequestInterface
*/
public static function fromFixture($path, TestCase $testCase)
{
$content = file_get_contents($path);
$lines = explode("\n", $content);
$request = $testCase->getMockBuilder(RequestInterface::class)->getMock();
$line = array_shift($lines);
list($method, $uri, $ver) = explode(' ', $line);
$request->expects(TestCase::any())->method('getMethod')->willReturn($method);
$headerValues = [];
$headers = [];
while (($line = array_shift($lines)) != "") {
list($key, $value) = explode(': ', $line);
$headers[$key] = $value;
$headerValues[$key] = explode(', ', $value);
}
$request->expects(TestCase::any())->method('getHeaders')->willReturn($headerValues);
$request->expects(TestCase::any())->method('getHeaderLine')->willReturnCallback(function ($key) use($headers) {
return isset($headers[$key]) ? $headers[$key] : null;
});
$request->expects(TestCase::any())->method('hasHeader')->willReturnCallback(function ($key) use($headers) {
return isset($headers[$key]);
});
$request->expects(TestCase::any())->method('getBody')->willReturn($body = join("\n", $lines));
return $request;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例13: 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;
}
示例14: createUndeclaredMethods
private function createUndeclaredMethods()
{
foreach (array_keys($this->originClassMethods) as $originalMethodName) {
if (false == array_key_exists($originalMethodName, $this->mockMethods)) {
$method = $this->mock->expects($this->testCase->any());
$method->method($originalMethodName);
$method->will($this->testCase->throwException(new UndeclaredMethodInvocationException($originalMethodName)));
}
}
}
示例15: 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));
}
}