/** * @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 WSDLBuilder $builder * @return WSDL */ public static function fromBuilder(WSDLBuilder $builder) { $xml = new XMLProvider($builder); $xml->generate(); return new self($xml->getXml()); }