示例#1
0
 /**
  * @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);
 }
 /**
  * @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();
 }
 protected function setUp()
 {
     parent::setUp();
     Route::clear();
     $this->path = Path::joinWithTemp(uniqid() . '_generated_uri_helper.js');
     Config::overrideProperty("global", "prefix_system")->with("/app");
 }
示例#4
0
 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');
 }
示例#5
0
 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>");
     }
 }
示例#6
0
文件: Layout.php 项目: letsdrink/ouzo
 public function renderLayout()
 {
     if ($this->_layout) {
         $layoutPath = Path::join(ROOT_PATH, ApplicationPaths::getLayoutPath(), $this->_layout . '.phtml');
         /** @noinspection PhpIncludeInspection */
         require_once $layoutPath;
     }
 }
示例#7
0
 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);
 }
示例#8
0
 private function _getConfigEnv()
 {
     $configPath = Path::join(ROOT_PATH, 'config', getenv('environment'), 'config.php');
     if (file_exists($configPath)) {
         /** @noinspection PhpIncludeInspection */
         return require $configPath;
     }
     return array();
 }
示例#9
0
 private function _getStubFilePath()
 {
     if ($this->shortArrays) {
         $stubFileName = 'class_short_arrays.stub';
     } else {
         $stubFileName = 'class.stub';
     }
     return Path::join(__DIR__, 'stubs', $stubFileName);
 }
示例#10
0
 /**
  * @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'));
 }
示例#11
0
文件: View.php 项目: letsdrink/ouzo
 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);
 }
示例#12
0
 /**
  * @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());
 }
示例#14
0
文件: I18n.php 项目: letsdrink/ouzo
 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;
 }
示例#15
0
 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;
 }
示例#16
0
 public function getClassDirectory()
 {
     return Path::join(ROOT_PATH, $this->resolvePathFromNameSpace(), $this->className);
 }
示例#17
0
 /**
  * @return void
  */
 private function includeRoutes()
 {
     $routesPath = Path::join(ROOT_PATH, 'config', 'routes.php');
     Files::loadIfExists($routesPath);
 }
示例#18
0
 /**
  * @test
  */
 public function shouldSaveGeneratedUriHelperInFile()
 {
     //given
     Route::resource('users');
     $fileName = uniqid() . '_GeneratedUriHelper.php';
     $path = Path::joinWithTemp($fileName);
     $generator = UriHelperGenerator::generate();
     //when
     $generator->saveToFile($path);
     //then
     $this->assertFileExists($path);
     $this->assertEquals($generator->getGeneratedFunctions(), file_get_contents($path));
     unlink($path);
 }
 private function stubFilePath()
 {
     return Path::join(__DIR__, 'stubs', 'class.stub');
 }
示例#20
0
 public static function getLayoutPath()
 {
     $controllerPath = Config::getValue('path', 'layout');
     return $controllerPath ? $controllerPath : Path::join('Application', 'Layout');
 }
示例#21
0
 protected function setUp()
 {
     parent::setUp();
     $this->controllerPath = Path::joinWithTemp('UsersController.php');
 }
示例#22
0
 private function _loadViewHelper()
 {
     $helperPath = Path::join(ROOT_PATH, ApplicationPaths::getViewPath(), $this->_viewName . '.helper.php');
     Files::loadIfExists($helperPath);
 }
示例#23
0
 public function isActionExists($actionFile)
 {
     return Files::exists(Path::join($this->getViewPath(), $actionFile));
 }
示例#24
0
 public static function resolveViewPath($name, $responseType)
 {
     return Path::join(ROOT_PATH, ApplicationPaths::getViewPath(), $name . self::getViewPostfix($responseType));
 }
示例#25
0
 /**
  * @test
  */
 public function shouldDeleteFileIfExists()
 {
     //given
     $filePath = Path::joinWithTemp('files_test');
     file_put_contents($filePath, 'test');
     //when
     $isDeleted = Files::deleteIfExists($filePath);
     //then
     $this->assertTrue($isDeleted);
     $this->assertFileNotExists($filePath);
 }
示例#26
0
<?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();
示例#27
0
 /**
  * @test
  */
 public function shouldRemoveDoubleSlashes()
 {
     //given
     $path = '//dir/file.txt';
     //when
     $normalized = Path::normalize($path);
     //then
     $this->assertEquals("/dir/file.txt", $normalized);
 }
示例#28
0
 public static function rpcLiteral()
 {
     return Path::join(__DIR__, 'generated_wsdl', 'rpc_literal.wsdl');
 }
示例#29
0
 /**
  * @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);
 }