Php Codeception SOAP命名空间

Php Codeception SOAP命名空间,php,soap,namespaces,codeception,Php,Soap,Namespaces,Codeception,在我的SoapCest.php中,我发送了一个Soap请求: $I->sendSoapRequest('authenticate', ['sUsername' => 'abc', 'sPassword' => 'xyz']); 这会导致XML错误: Procedure 'ns:authenticate' not present 这是正确的,因为应该使用soap:authenticate而不是ns:authenticate调用请求 如何更改codeception中用于测试调用

在我的
SoapCest.php
中,我发送了一个Soap请求:

$I->sendSoapRequest('authenticate', ['sUsername' => 'abc', 'sPassword' => 'xyz']);
这会导致XML错误:

Procedure 'ns:authenticate' not present
这是正确的,因为应该使用
soap:authenticate
而不是
ns:authenticate
调用请求


如何更改codeception中用于测试调用的命名空间
ns:

我希望能为您的需要提供一些想法

在我的情况下,我也必须改变NS。但是构建只包含1个wsdl。因此,您有两种选择:“将模块分叉并使其适应您的需要”或“修改该模块的行为”

我选了第二个

我的SOAP测试是这样开始的:

Class SiteRedshopbCategory100SoapCest
{
public function _before(ApiTester $I, \Helper\SoapModule $soapModule, \Codeception\TestCase\Cest $testCase)
{
    $endpoint = 'http://mywebsite.com/index.php?webserviceClient=site&webserviceVersion=1.0.0&view=category&api=soap';
    $schema = $I->getSoapWsdlDinamically($endpoint);

    $soapModule->configure(
            $testCase,
            $endpoint,
            $schema
    );
}

public function create(ApiTester $I)
{
    $I->wantTo('POST a new category using SOAP');
    $I->amHttpAuthenticated('admin', 'admin');
    $I->sendSoapRequest('create', "<name>Category1</name>");
    $I->seeSoapResponseContainsStructure("<result></result>");
    $I->dontSeeSoapResponseIncludes("<result>false</result>");
}

更新:2016年2月17日 我在下面的评论中添加了请求的助手

需要在以下位置创建:tests/_support/Helper/文件夹(您可以使用命令
vendor/bin/codecept generate:Helper SoapModule
生成它)


更新:以前的代码对Codeception 2.1有效。使用Codeception 2.2这不再有效。请检查:

在2.5版中,您可以执行以下操作:


谢谢你的帖子!你能解释一下你的
\Helper\SoapModule$SoapModule
是从哪里来的吗?里面有哪些内容?现在我遇到以下错误:
[InjectionException]未能在“tests\api\SoapCest”的实例中注入依赖项。Class tests\api\Codeception\Module\SOAP不存在
——或者如果我更改类名,则不存在类似的问题。噢!好的,您需要在:tests/_support/helper处创建SoapModule帮助程序。再次查看文章,我已经更新了它。
class ApiHelper extends \Codeception\Module
{
    /**
     * Cached WSDL files
     */
    static private $schemas = [];

    /**
     * Returns the location of the Wsdl file generated dinamically
     *
     * @param   string  $endpoint  The webservice url.
     *
     * @return mixed
     */
    public function getSoapWsdlDinamically($endpoint)
    {
        // Gets cached WSDL static file from dynamic file
        if (!isset(self::$schemas[$endpoint]))
        {
            $wsdl = simplexml_load_file($endpoint . '&wsdl');
            $schema = $wsdl['targetNamespace'];
            self::$schemas[$endpoint] = $schema;
        }

        return self::$schemas[$endpoint];
    }
<?php
namespace Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class SoapModule extends \Codeception\Module
{
    public function configure($testcase, $endpoint, $schema)
    {
        $this->getModule('SOAP')->_reconfigure(
            array(
                'endpoint' => $endpoint,
                'schema' => $schema,
            )
        );
        //$this->getModule('SOAP')->buildRequest();
        $this->getModule('SOAP')->_before($testcase);
    }
}