/** * @inheritDoc */ public function disable() { self::$requestCallback = null; stream_wrapper_restore('http'); stream_wrapper_restore('https'); $this->status = self::DISABLED; }
/** * 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; }
public static function restoreDefault() { // Reset static values self::$_returnValues = array(); self::$_arguments = array(); // Restore original stream wrapper stream_wrapper_restore('php'); }
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); }
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"); }
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); }
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"); }
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"); }
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(); }
/** * 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; }
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']); }
/** * 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; }
/** * * @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'); }
/** * 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; }
/** * @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"); }
public function url_stat($path, $flags) { restore_error_handler(); //запрос stat проводим к реальной файловой системе stream_wrapper_restore("file") or die(__FILE__ . __LINE__); //$filename = self::parse_path(parse_url($path,PHP_URL_PATH)); // если адрес выполняемого скрипта фейковый, то просто подставляем исполняемый файл //if(file_exists($filename)) { // $stat=stat($filename); //} else { $stat = stat(__FILE__); //} stream_wrapper_unregister("file") or die(__FILE__ . __LINE__); stream_wrapper_register("file", get_class($this)) or die(__FILE__ . __LINE__); //set_error_handler(array(static::CLASSNAME,"xsltErrorHandler")); return $stat; }
function callWsMethod($methodName, $paramArray) { try { if ($methodName == 'DeleteDws' || $methodName == 'GetListCollection') { $strResult = ""; $strResult = $this->client->{$methodName}($paramArray = ""); return $strResult; } else { $strResult = ""; $strResult = $this->client->{$methodName}($paramArray); return $strResult; } } catch (SoapFault $fault) { echo 'Fault code: ' . $fault->faultcode; echo 'Fault string: ' . $fault->faultstring; } stream_wrapper_restore('http'); }
/** * * @param string $wsdl * @param array $options */ public function __construct($wsdl, $options = NULL) { $wrappers = stream_get_wrappers(); stream_wrapper_unregister('http'); stream_wrapper_register('http', '\\Thybag\\Auth\\StreamWrapperHttpAuth'); if (in_array("https", $wrappers)) { stream_wrapper_unregister('https'); stream_wrapper_register('https', '\\Thybag\\Auth\\StreamWrapperHttpAuth'); } if ($options) { $this->Username = $options['login']; \Thybag\Auth\StreamWrapperHttpAuth::$Username = $this->Username; $this->Password = $options['password']; \Thybag\Auth\StreamWrapperHttpAuth::$Password = $this->Password; } parent::SoapClient($wsdl, $options ? $options : array()); stream_wrapper_restore('http'); if (in_array("https", $wrappers)) { stream_wrapper_restore('https'); } }
/** * * @param String $url The WSDL url * @param Array $data Soap options, it should contain ntlm_username and ntlm_password fields * @param LoggerAwareInterface|LoggerInterface $logger * @throws Exception * @see \SoapClient::__construct() */ public function __construct($url, $data, LoggerInterface $logger = null) { if ($logger) { $this->setLogger($logger); } $this->options = $data; if (empty($data['ntlm_username']) && empty($data['ntlm_password'])) { parent::__construct($url, $data); } else { $this->use_ntlm = true; HttpStream\NTLMStream::$user = $data['ntlm_username']; HttpStream\NTLMStream::$password = $data['ntlm_password']; stream_wrapper_unregister('http'); if (!stream_wrapper_register('http', '\\NTLMSoap\\HttpStream\\NTLMStream')) { throw new Exception("Unable to register HTTP Handler"); } $time_start = microtime(true); parent::__construct($url, $data); if (!empty($this->logger) && ($end_time = microtime(true) - $time_start) > 0.1) { $this->logger->debug("WSDL Timer", array("time" => $end_time, "url" => $url)); } stream_wrapper_restore('http'); } }
/** * Restores the original file stream wrapper status. * * @return void */ public function restore() { stream_wrapper_restore(self::PROTOCOL); }
/** * Restore an internal stream wrapper. * * @param string $protocol The protocol of the stream wrapper to restore. * @return void */ public static function restoreWrapper($protocol) { stream_wrapper_restore($protocol); }
<?php require_once "ntlm/NTLMStream.php"; require_once "ntlm/NTLMSoapClient.php"; //Aici e definit domeniul, userul si parola stream_wrapper_unregister('http'); stream_wrapper_register('http', 'NTLMStream') or die("Failed to register protocol"); // Initialize Soap Client $baseURL = 'http://86.35.240.116:7149/Test/WS/Test_UnicSpot%20-%20Productie/Page/'; $client = new NTLMSoapClient($baseURL . 'SiteIntegrationCustomer'); // La linia asta apare eroarea respectiva // Find the first Company in the Companies $result = $client->Companies(); $companies = $result->return_value; echo "Companies:<br>"; if (is_array($companies)) { foreach ($companies as $company) { echo "{$company}<br>"; } $cur = $companies[0]; } else { echo "{$companies}<br>"; $cur = $companies; } stream_wrapper_restore('http'); ?>
/** * Unregisters protocol. * * @return boolean */ public static function unregister() { return stream_wrapper_restore('php'); }
function test_stream_wrapper_restore() { $count = count(stream_get_wrappers()); VS(stream_wrapper_unregister("http"), true); VS(count(stream_get_wrappers()), $count - 1); VS(stream_wrapper_restore("http"), true); VS(count(stream_get_wrappers()), $count); }
/** * Tears down stream handling. Internally used. * * @access private * @return void */ private function teardown() { stream_wrapper_restore('http'); stream_wrapper_restore('https'); }
<?php var_dump(stream_wrapper_unregister('file')); var_dump(fopen("file://" . __FILE__, "r")); var_dump(stream_wrapper_restore('file')); var_dump(fopen("file://" . __FILE__, "r")); echo "Done\n";
/** * @group ZF-7756 */ public function testCallingGetRawBodyMultipleTimesShouldReturnSameValue() { require_once 'Zend/AllTests/StreamWrapper/PhpInput.php'; Zend_AllTests_StreamWrapper_PhpInput::mockInput('foobar'); $request = new Zend_Controller_Request_Http(); $first = $request->getRawBody(); $this->assertSame($first, $request->getRawBody()); stream_wrapper_restore('php'); }
public static function disable() { stream_wrapper_restore('file'); }
public function url_stat($path, $flags) { $data = []; stream_wrapper_restore('file'); if ($flags & STREAM_URL_STAT_LINK) { $data = @lstat($path); } else { $data = @stat($path); } stream_wrapper_unregister('file'); stream_wrapper_register('file', __CLASS__, 0); return $data; }
public static function unregister() { stream_wrapper_restore(static::$protocol); static::$registered = false; }