/** * @return Soap|\SoapClient */ protected function _getClient() { $host = Env::get('WEB_HOST', '127.0.0.1', Env::VAR_STRING); $port = Env::get('WEB_PORT', '8081', Env::VAR_STRING); $loc = Url::create(['host' => $host, 'port' => $port, 'path' => 'wsSSMaker.asmx']); /** @var Soap $client */ $client = new \SoapClient($loc . '?WSDL', ['trace' => true, 'location' => $loc]); return $client; }
/** * @param $testName * @param $request * @return Data */ public function request($testName, $request) { $cms = Cms::getInstance(); $host = Env::get('TEST_HOST', '127.0.0.1'); $port = Env::get('TEST_PORT'); $url = Url::create(['host' => $host, 'port' => $port]); $result = httpRequest($url, array_merge(['jbzoo-phpunit' => 1, 'jbzoo-phpunit-test' => $this->getTestName($testName), 'jbzoo-phpunit-type' => strtolower($cms['type'])], $request), 'GET', ['allow_redirects' => false, 'exceptions' => false, 'timeout' => 60, 'verify' => false]); if (!$result->getCode()) { var_dump($result); } return $result; }
use JBZoo\Utils\Env; use JBZoo\Utils\Url; use Slim\Http\Request; use Slim\Http\Response; $_SERVER['SCRIPT_NAME'] = '/index.php'; // #F**K!!! https://bugs.php.net/bug.php?id=61286 if (!isset($app)) { // For PHPUnit reports return; } /** @var \Slim\App $app */ $app->any('/wsSSMaker.asmx', function (Request $req, Response $resp) { $serverHost = Env::get('WEB_HOST', $_SERVER['HTTP_HOST'], Env::VAR_STRING); $serverPort = Env::get('WEB_PORT', $_SERVER['SERVER_PORT'], Env::VAR_STRING); $cleanHost = str_replace(':' . $serverPort, '', $serverHost); $location = Url::create(['host' => $cleanHost, 'port' => $serverPort, 'path' => '/wsSSMaker.asmx']); $wsdlFile = __DIR__ . '/ssmaker.wsdl'; if ($req->getParam('WSDL') === '') { /** @var Response $resp */ $resp = $resp->withHeader('Expires', 'Wed, 11 Jan 1984 05:00:00 GMT'); $resp = $resp->withHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT'); $resp = $resp->withHeader('Cache-Control', 'no-cache, must-revalidate, max-age=0'); $resp = $resp->withHeader('Pragma', 'no-cache'); $resp = $resp->withHeader('Content-type', 'application/wsdl+xm'); $resp->getBody()->write(file_get_contents($wsdlFile)); return $resp; } else { $server = new SoapServer($wsdlFile, ['location' => $location]); $server->setClass('JBZoo\\SSmakerServer\\Soap'); $server->handle(); }
public function testCreate() { isSame('http://example.com/?foo=bar', Url::create(array('host' => 'example.com', 'user' => '', 'pass' => '123456', 'query' => array('foo' => 'bar')))); isSame('http://example.com/', Url::create(array('host' => 'example.com', 'part' => ''))); isSame('ssh://example.com/', Url::create(array('host' => 'example.com', 'scheme' => 'ssh', 'part' => ''))); isSame('http://example.com/', Url::create(array('host' => 'example.com', 'port' => 80))); isSame('https://example.com/', Url::create(array('host' => 'example.com', 'port' => 443))); isSame('http://example.com/page#hash', Url::create(array('host' => 'example.com', 'path' => 'page', 'fragment' => 'hash'))); isSame('https://*****:*****@example.com/page?foo=bar#hash', Url::create(array('scheme' => 'https', 'host' => 'example.com', 'user' => 'user', 'pass' => '123456', 'path' => 'page', 'query' => array('foo' => 'bar'), 'fragment' => '#hash'))); }