本文整理汇总了PHP中stream_wrapper_restore函数的典型用法代码示例。如果您正苦于以下问题:PHP stream_wrapper_restore函数的具体用法?PHP stream_wrapper_restore怎么用?PHP stream_wrapper_restore使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stream_wrapper_restore函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: disable
/**
* @inheritDoc
*/
public function disable()
{
self::$requestCallback = null;
stream_wrapper_restore('http');
stream_wrapper_restore('https');
$this->status = self::DISABLED;
}
示例2: endTestSuite
/**
* Restore PHP built-in HTTP stream wrapper and perform any other clean-up.
*
* @param \PHPUnit_Framework_TestSuite $suite
* @return bool
*/
public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
{
foreach ($this->wrappers as $wrapper) {
\stream_wrapper_restore($wrapper);
}
return TRUE;
}
示例3: restoreDefault
public static function restoreDefault()
{
// Reset static values
self::$_returnValues = array();
self::$_arguments = array();
// Restore original stream wrapper
stream_wrapper_restore('php');
}
示例4: tearDownAfterClass
public static function tearDownAfterClass()
{
// Restore the built-in HTTP wrapper for other unit tests.
\stream_wrapper_restore('http');
// Clean up all ignore files.
$removeFiles = \glob(FIXTURES_PATH . DIRECTORY_SEPARATOR . 'ignore*');
\array_map('unlink', $removeFiles);
}
示例5: testCanGetRawPostDataFromInputStream
public function testCanGetRawPostDataFromInputStream()
{
stream_wrapper_unregister("php");
stream_wrapper_register("php", PhpStreamMock::class);
file_put_contents('php://input', 'Unit-Test');
$postRequest = new PostRequest(RequestInfo::fromEnv(), [], []);
$this->assertEquals('Unit-Test', $postRequest->getRawData());
stream_wrapper_restore("php");
}
示例6: tearDownAfterClass
public static function tearDownAfterClass()
{
\stream_wrapper_restore('http');
\stream_wrapper_restore('https');
// TODO: Move this where it will execute after the entire suite runs.
// Clean up all ignore files.
$removeFiles = \glob(FIXTURES_PATH . DIRECTORY_SEPARATOR . 'ignore*');
\array_map('unlink', $removeFiles);
}
示例7: testCanCreateFromRawPost
public function testCanCreateFromRawPost()
{
// Prep php://input with mocked data
MockPhpStream::setStartingData(json_encode($this->messageData));
stream_wrapper_unregister('php');
stream_wrapper_register('php', __NAMESPACE__ . '\\MockPhpStream');
$message = Message::fromRawPostData();
$this->assertInstanceOf('Aws\\Sns\\MessageValidator\\Message', $message);
stream_wrapper_restore("php");
}
示例8: testCanAccessRawDataFromRequest
public function testCanAccessRawDataFromRequest()
{
stream_wrapper_unregister("php");
stream_wrapper_register("php", PhpStreamMock::class);
file_put_contents('php://input', 'Unit-Test');
$postRequest = new PostRequest(RequestInfo::fromEnv(), [], []);
$command = new TestDomainCommand($postRequest);
$this->assertEquals('Unit-Test', $command->getBody());
stream_wrapper_restore("php");
}
示例9: reset
public static function reset()
{
foreach (self::$existingWrappers as $wrapper) {
stream_wrapper_unregister($wrapper);
if (in_array($wrapper, self::$originalWrappers)) {
stream_wrapper_restore($wrapper);
}
}
self::$originalWrappers = array();
self::$existingWrappers = array();
}
示例10: capture
/**
* Capture output
*
* @param lang.Runnable r
* @param array<string, string> initial
* @return array<string, string>
*/
public static function capture(Runnable $r, $initial = [])
{
self::$streams = $initial;
stream_wrapper_unregister('php');
stream_wrapper_register('php', __CLASS__);
try {
$r->run();
} finally {
stream_wrapper_restore('php');
}
return self::$streams;
}
示例11: testCanCreateFromRawPost
public function testCanCreateFromRawPost()
{
$_SERVER['HTTP_X_AMZ_SNS_MESSAGE_TYPE'] = 'Notification';
// Prep php://input with mocked data
MockPhpStream::setStartingData(json_encode($this->messageData));
stream_wrapper_unregister('php');
stream_wrapper_register('php', __NAMESPACE__ . '\\MockPhpStream');
$message = Message::fromRawPostData();
$this->assertInstanceOf('Aws\\Sns\\Message', $message);
stream_wrapper_restore("php");
unset($_SERVER['HTTP_X_AMZ_SNS_MESSAGE_TYPE']);
}
示例12: locateClassByName
/**
* Attempt to locate a class by name.
*
* If class already exists, simply use internal reflection API to get the
* filename and store it.
*
* If class does not exist, we make an assumption that whatever autoloaders
* that are registered will be loading a file. We then override the file://
* protocol stream wrapper to "capture" the filename we expect the class to
* be in, and then restore it. Note that class_exists will cause an error
* that it cannot find the file, so we squelch the errors by overriding the
* error handler temporarily.
*
* @param string $className
* @return string
*/
private function locateClassByName($className)
{
if (class_exists($className, false) || interface_exists($className, false) || trait_exists($className, false)) {
return (new \ReflectionClass($className))->getFileName();
}
self::$autoloadLocatedFile = null;
$previousErrorHandler = set_error_handler(function () {
});
stream_wrapper_unregister('file');
stream_wrapper_register('file', self::class);
class_exists($className);
stream_wrapper_restore('file');
set_error_handler($previousErrorHandler);
return self::$autoloadLocatedFile;
}
示例13: SoapClientAuth
/**
*
* @param string $wsdl
* @param array $options
*/
function SoapClientAuth($wsdl, $options = NULL)
{
stream_wrapper_unregister('https');
stream_wrapper_unregister('http');
stream_wrapper_register('https', 'streamWrapperHttpAuth');
stream_wrapper_register('http', 'streamWrapperHttpAuth');
if ($options) {
$this->Username = $options['login'];
streamWrapperHttpAuth::$Username = $this->Username;
$this->Password = $options['password'];
streamWrapperHttpAuth::$Password = $this->Password;
}
parent::SoapClient($wsdl, $options ? $options : array());
stream_wrapper_restore('https');
stream_wrapper_restore('http');
}
示例14: capture
/**
* Capture output
*
* @param lang.Runnable r
* @param array<string, string> initial
* @return array<string, string>
*/
public static function capture(Runnable $r, $initial = array())
{
self::$streams = $initial;
stream_wrapper_unregister('php');
stream_wrapper_register('php', __CLASS__);
try {
$r->run();
} catch (Exception $e) {
}
ensure($e);
stream_wrapper_restore('php');
if ($e) {
throw $e;
}
return self::$streams;
}
示例15: testCanGetBodyDataFromInputStream
/**
* @runInSeparateProcess
*/
public function testCanGetBodyDataFromInputStream()
{
stream_wrapper_unregister("php");
stream_wrapper_register("php", PhpStreamMock::class);
file_put_contents('php://input', 'body data');
$requestInfo = new RequestInfo(['REQUEST_METHOD' => 'POST', 'REQUEST_URI' => '/domain/test_body_data']);
$expectedWriteRequest = new WriteRequest($requestInfo, new WriteRequestInput('body data', []));
$requestHandler = $this->getMockBuilder(HandlesPostRequest::class)->getMockForAbstractClass();
$requestHandler->expects($this->once())->method('handle')->with($this->equalTo($expectedWriteRequest));
$writeRoute = new WriteRoute(new Literal('/domain/test_body_data'), $requestHandler);
$config = $this->getMockBuilder(ConfiguresIceHawk::class)->getMockForAbstractClass();
$config->method('getRequestInfo')->willReturn($requestInfo);
$config->expects($this->once())->method('getWriteRoutes')->willReturn([$writeRoute]);
$writeRequestHandler = new WriteRequestHandler($config, new EventPublisher());
$writeRequestHandler->handleRequest();
stream_wrapper_restore("php");
}