/** * @param string $class */ public function __construct($class) { AnnotationRegistry::registerAutoloadNamespace('WSDL\\Annotation', Path::join(__DIR__, '..', '..')); $this->class = $class; $this->builder = WSDLBuilder::instance(); $this->annotationReader = new AnnotationReader(); }
/** * @test */ public function shouldGenerateCorrectXML() { //given $tokenizer = new Tokenizer(); $parameters1 = [Parameter::fromTokens($tokenizer->lex('string $userName'))]; $return1 = Parameter::fromTokens($tokenizer->lex('string $uppercasedUserName')); $parameters2 = [Parameter::fromTokens($tokenizer->lex('int[] $numbers')), Parameter::fromTokens($tokenizer->lex('string $prefix'))]; $return2 = Parameter::fromTokens($tokenizer->lex('string[] $numbersWithPrefix')); $parameters3 = [Parameter::fromTokens($tokenizer->lex('object $user { string $name int $age }'))]; $return3 = Parameter::fromTokens($tokenizer->lex('object $userContext { int $id object $userInfo { string $name int $age } }')); $parameters4 = [Parameter::fromTokens($tokenizer->lex('object[] $companies { string $name int $postcode }'))]; $return4 = Parameter::fromTokens($tokenizer->lex('string[] $companiesNames')); $parameters5 = [Parameter::fromTokens($tokenizer->lex('string[] $errors'))]; $return5 = Parameter::fromTokens($tokenizer->lex('object $result { boolean $result string[] $errors }')); $parameters6 = [Parameter::fromTokens($tokenizer->lex('object $serviceAuth { string $token int $id }'), true), Parameter::fromTokens($tokenizer->lex('string $name')), Parameter::fromTokens($tokenizer->lex('string $surname'))]; $return6 = Parameter::fromTokens($tokenizer->lex('string $nameWithSurname')); $parameters7 = [Parameter::fromTokens($tokenizer->lex('string $userToken'))]; $return8 = Parameter::fromTokens($tokenizer->lex('string $responseForMethodWithoutParameters')); $builder = WSDLBuilder::instance()->setName('RpcLiteralService')->setTargetNamespace('http://foo.bar/rpcliteralservice')->setNs('http://foo.bar/rpcliteralservice/types')->setLocation('http://localhost:7777/wsdl-creator/examples/rpc_literal/service.php')->setStyle(SoapBinding::RPC)->setUse(SoapBinding::LITERAL)->setSoapVersion(BindingType::SOAP_11)->setMethod(new Method('uppercaseUserName', $parameters1, $return1))->setMethod(new Method('appendPrefixToNumbers', $parameters2, $return2))->setMethod(new Method('getUserContext', $parameters3, $return3))->setMethod(new Method('extractCompaniesNames', $parameters4, $return4))->setMethod(new Method('wrapErrors', $parameters5, $return5))->setMethod(new Method('authorizedMethod', $parameters6, $return6))->setMethod(new Method('methodWithoutReturn', $parameters7, null))->setMethod(new Method('methodWithoutParameters', [], $return8)); $XMLProvider = new XMLProvider($builder); $XMLProvider->generate(); //when $xml = $XMLProvider->getXml(); //then $this->assertXmlStringEqualsXmlFile(Path::join(__DIR__, 'xml_file_asserts', 'correct_xml.wsdl'), $xml); }
public function setUp() { $this->directory = Path::joinWithTemp('directory_class'); mkdir($this->directory, 0777, true); file_put_contents(Path::join($this->directory, 'file1.txt'), 'test'); file_put_contents(Path::join($this->directory, 'file2.txt'), 'some new file'); }
private function generateJsHelper() { $routesJSHelperPath = $this->_input->getOption('path'); $routesJSHelperPath = Path::join($routesJSHelperPath, 'generated_uri_helper.js'); if (JsUriHelperGenerator::generate()->saveToFile($routesJSHelperPath) !== false) { $this->_output->writeln("File with JS uri helpers is generated in <info>{$routesJSHelperPath}</info>"); } }
public function renderLayout() { if ($this->_layout) { $layoutPath = Path::join(ROOT_PATH, ApplicationPaths::getLayoutPath(), $this->_layout . '.phtml'); /** @noinspection PhpIncludeInspection */ require_once $layoutPath; } }
public function __construct($viewName, array $attributes) { $this->_viewName = $viewName; $this->_attributes = $attributes; $this->_loaderPath = Path::join(ROOT_PATH, ApplicationPaths::getViewPath()); $this->_viewFilename = $viewName . self::EXTENSION; $this->_viewPath = Path::join($this->_loaderPath, $this->_viewFilename); }
/** * @test */ public function shouldJoinPathWithSeparatorSkippingEmptyElements() { // given $s = DIRECTORY_SEPARATOR; // when $path = Path::join('my', '', '/file.txt'); // then $this->assertEquals("my{$s}file.txt", $path); }
private function _getConfigEnv() { $configPath = Path::join(ROOT_PATH, 'config', getenv('environment'), 'config.php'); if (file_exists($configPath)) { /** @noinspection PhpIncludeInspection */ return require $configPath; } return array(); }
private function _getStubFilePath() { if ($this->shortArrays) { $stubFileName = 'class_short_arrays.stub'; } else { $stubFileName = 'class.stub'; } return Path::join(__DIR__, 'stubs', $stubFileName); }
/** * @test */ public function shouldResolveDirectoryPath() { //given $resolver = ClassPathResolver::forClassAndNamespace('UserAcl', '\\Application\\View'); //when $directoryPath = $resolver->getClassDirectory(); //then Assert::thatString($directoryPath)->endsWith(Path::join('Application', 'View', 'UserAcl')); }
private function _loadHelpers() { $viewHelperPath = Path::join('Helper', 'ViewHelper.php'); $appHelperPath = Path::join(ROOT_PATH, ApplicationPaths::getHelperPath(), 'ApplicationHelper.php'); $formHelperPath = Path::join('Helper', 'FormHelper.php'); $urlHelperPath = Path::join(ROOT_PATH, ApplicationPaths::getHelperPath(), 'UrlHelper.php'); $this->_requireOnce($viewHelperPath); Files::loadIfExists($appHelperPath); $this->_requireOnce($formHelperPath); Files::loadIfExists($urlHelperPath); }
/** * @test */ public function shouldAppendViewFile() { //given $viewGenerator = new ViewGenerator('users', $this->path); $viewGenerator->createViewDirectoryIfNotExists(); $actionGenerator = new ActionGenerator('save'); //when $appendAction = $viewGenerator->appendAction($actionGenerator); //then $this->assertTrue($appendAction); $this->assertFileExists(Path::join($this->path, $actionGenerator->getActionViewFile())); }
/** * @test */ public function shouldAddFile() { //given $document = new Document(array('document_name' => 'new document test', 'revision' => '1')); $document->insert(); $content = file_get_contents(Path::join(__DIR__, '..', '..', 'Resources', 'soapui-settings.xml')); $fileName = 'soapui-settings.xml'; //when $document->uploadFile($content, $fileName); //then $file = $document->getFile(); $this->assertEquals($fileName, $file->getFileName()); }
public static function loadLabels() { if (!self::$_labels) { $language = self::getLanguage(); $path = Path::join(ROOT_PATH, 'locales', $language . '.php'); if (!Files::exists($path)) { throw new Exception('Cannot find declared language file: ' . $language); } /** @noinspection PhpIncludeInspection */ self::$_labels = (require $path); } return self::$_labels; }
public function append() { if ($this->controllerGenerator) { $controllerPath = $this->controllerGenerator->getControllerPath(); $controllerContents = $this->controllerGenerator->getControllerContents(); $actionContents = $this->actionGenerator->templateContents(); $controllerContents = preg_replace('/}\\s*$/', $actionContents . PHP_EOL . '}' . PHP_EOL, $controllerContents); file_put_contents($controllerPath, $controllerContents); } if ($this->viewGenerator) { file_put_contents(Path::join($this->viewGenerator->getViewPath(), $this->actionGenerator->getActionViewFile()), PHP_EOL); } return true; }
public function getClassDirectory() { return Path::join(ROOT_PATH, $this->resolvePathFromNameSpace(), $this->className); }
/** * @return void */ private function includeRoutes() { $routesPath = Path::join(ROOT_PATH, 'config', 'routes.php'); Files::loadIfExists($routesPath); }
private function stubFilePath() { return Path::join(__DIR__, 'stubs', 'class.stub'); }
public static function getLayoutPath() { $controllerPath = Config::getValue('path', 'layout'); return $controllerPath ? $controllerPath : Path::join('Application', 'Layout'); }
public static function resolveViewPath($name, $responseType) { return Path::join(ROOT_PATH, ApplicationPaths::getViewPath(), $name . self::getViewPostfix($responseType)); }
private function _loadViewHelper() { $helperPath = Path::join(ROOT_PATH, ApplicationPaths::getViewPath(), $this->_viewName . '.helper.php'); Files::loadIfExists($helperPath); }
public function isActionExists($actionFile) { return Files::exists(Path::join($this->getViewPath(), $actionFile)); }
/** * @test */ public function shouldReturnMimeType() { //given $path = Path::join(ROOT_PATH, 'test', 'resources', 'logo.png'); //when $mimeType = Files::mimeType($path); //then $this->assertEquals('image/png', $mimeType); }
<?php use Ouzo\Utilities\Clock; use Ouzo\Utilities\Files; use Ouzo\Utilities\Path; error_reporting(E_ALL); putenv('environment=test'); define('ROOT_PATH', realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR); require 'vendor/autoload.php'; Files::loadIfExists(Path::join(ROOT_PATH, 'config', 'error_codes.php')); Files::loadIfExists(Path::join(ROOT_PATH, 'config', 'routes.php')); Clock::freeze();
/** * @test */ public function shouldCorrectCreateWsdlWithMultipleWrappersForDocumentLiteralWrapped() { //given XMLGenerator::$alreadyGeneratedComplexTypes = array(); $classParser = new ClassParser('\\Mocks\\MockMultipleWrappers'); $classParser->parse(); $xml = new XMLGenerator('\\Mocks\\MockMultipleWrappers', $this->_namespace, $this->_location); $xml->setWSDLMethods($classParser->getMethods())->setBindingStyle(new DocumentLiteralWrapped())->generate(); //when $wsdl = $xml->getGeneratedXML(); //then $file = Path::join(__DIR__, 'xml_file_asserts', 'multiple_wrappers.wsdl'); $this->assertXmlStringEqualsXmlFile($file, $wsdl); }
public static function rpcLiteral() { return Path::join(__DIR__, 'generated_wsdl', 'rpc_literal.wsdl'); }