本文整理汇总了PHP中AspectMock\Test::func方法的典型用法代码示例。如果您正苦于以下问题:PHP Test::func方法的具体用法?PHP Test::func怎么用?PHP Test::func使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AspectMock\Test
的用法示例。
在下文中一共展示了Test::func方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _before
/**
* executed before each test
*/
public function _before()
{
$this->markTestSkipped('Mocking up php functions doesnt work for zephir extensions.');
$_FILES = ['photo' => ['name' => ['f0', 'f1', ['f2', 'f3'], [[[['f4']]]]], 'type' => ['text/plain', 'text/csv', ['image/png', 'image/jpeg'], [[[['application/octet-stream']]]]], 'tmp_name' => ['t0', 't1', ['t2', 't3'], [[[['t4']]]]], 'error' => [0, 0, [0, 0], [[[[8]]]]], 'size' => [10, 20, [30, 40], [[[[50]]]]]]];
$request = new Request();
$request->setDI($this->tester->getApplication()->getDI());
$uploadedFiles = $request->getUploadedFiles();
$files = [];
/** @var Request\File $file */
foreach ($uploadedFiles as $file) {
$files[] = ['name' => $file->getName(), 'tmp_name' => $file->getTempName(), 'type' => $file->getType(), 'size' => $file->getSize(), 'error' => $file->getError()];
}
$this->files = $files;
Test::func('Phalcon\\Validation\\Validator', 'getimagesize', function ($tmpName) {
$tmpSizes = ['t0' => null, 't1' => null, 't2' => [500, 500], 't3' => [1000, 1000], 't4' => null];
return $tmpSizes[$tmpName];
});
Test::func('Phalcon\\Validation\\Validator', 'finfo_open', function ($mimeType) {
return null;
});
Test::func('Phalcon\\Validation\\Validator', 'finfo_file', function ($tmp, $tmpName) {
$tmpTypes = ['t0' => 'text/plain', 't1' => 'text/csv', 't2' => 'image/png', 't3' => 'image/jpeg', 't4' => 'application/octet-stream'];
return $tmpTypes[$tmpName];
});
Test::func('Phalcon\\Validation\\Validator', 'is_uploaded_file', function ($tmpName) {
return true;
});
Test::func('Phalcon\\Validation\\Validator', 'finfo_close', function ($tmp, $tmpName) {
});
$_SERVER["REQUEST_METHOD"] = "POST";
}
示例2: _before
protected function _before()
{
$_SERVER = array_merge($_SERVER, ['HTTP_HOST' => 'localhost', 'SERVER_PORT' => '80', 'REQUEST_URI' => '/test']);
//Mocking mkdir()
test::func('nlac', 'mkdir', function ($dir = '') {
});
}
示例3: setUp
protected function setUp()
{
$this->out = fopen('php://memory', 'w');
$this->listener = new TestListener($this->out);
// mock standard php functions output
AspectMock\Test::func('PHPUnit\\TeamCity', 'date', '2015-05-28T16:14:12.17+0700');
AspectMock\Test::func('PHPUnit\\TeamCity', 'getmypid', 24107);
}
示例4: testFailedVerification
public function testFailedVerification()
{
$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
$func = test::func('demo', 'strlen', function () {
return 10;
});
expect(strlen('hello'))->equals(10);
$func->verifyNeverInvoked('strlen');
}
示例5: testCall
public function testCall()
{
$request = $this->prepareRequest();
// check if curl is not installed
test::func('esia', 'curl_init', false);
$response = $request->call('stub');
$this->assertNull($response);
// check if correct call
test::clean();
test::func('esia', 'curl_exec', '{}');
$response = $request->call('stub');
$this->assertTrue($response instanceof \stdClass);
}
示例6: testSignPKCS7
public function testSignPKCS7()
{
$openId = $this->prepareOpenId();
$checkException = function ($func, $expectedCode) use($openId) {
try {
test::func('esia', $func, false);
$openId = $this->prepareOpenId();
$openId->signPKCS7('message');
$errorMessage = sprintf('Exception %s isn\'t rise with code %d', SignFailException::class, $expectedCode);
$this->fail($errorMessage);
} catch (SignFailException $e) {
$message = 'Exception rise with wrong code';
$this->assertEquals($e->getCode(), $expectedCode, $message);
}
test::clean();
};
$checkException('openssl_x509_read', SignFailException::CODE_CANT_READ_CERT);
$checkException('openssl_pkey_get_private', SignFailException::CODE_CANT_READ_PRIVATE_KEY);
$checkException('openssl_pkcs7_sign', SignFailException::CODE_SIGN_FAIL);
// check correct call
$result = $openId->signPKCS7('message');
$this->assertInternalType('string', $result);
}