2011-09-03 21:15:51 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the BeSimpleSoapBundle.
|
|
|
|
*
|
|
|
|
* (c) Christian Kerl <christian-kerl@web.de>
|
|
|
|
* (c) Francis Besset <francis.besset@gmail.com>
|
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
2011-09-04 00:42:51 +02:00
|
|
|
namespace BeSimple\Tests\SoapClient;
|
2011-09-03 21:15:51 +02:00
|
|
|
|
2011-09-04 00:42:51 +02:00
|
|
|
use BeSimple\SoapClient\SoapRequest;
|
2011-09-03 21:15:51 +02:00
|
|
|
|
|
|
|
class SoapRequestTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
public function testSetFunction()
|
|
|
|
{
|
|
|
|
$soapRequest = new SoapRequest();
|
|
|
|
$soapRequest->setFunction('foo');
|
|
|
|
|
|
|
|
$this->assertEquals('foo', $soapRequest->getFunction());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetArguments()
|
|
|
|
{
|
|
|
|
$soapRequest = new SoapRequest();
|
|
|
|
$arguments = array(
|
|
|
|
'foo' => true,
|
|
|
|
'bar' => false,
|
|
|
|
);
|
|
|
|
$soapRequest->setArguments($arguments);
|
|
|
|
|
|
|
|
$this->assertEquals($arguments, $soapRequest->getArguments());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetArgument()
|
|
|
|
{
|
|
|
|
$soapRequest = new SoapRequest();
|
|
|
|
|
2011-09-04 23:42:03 +02:00
|
|
|
$this->assertSame(null, $soapRequest->getArgument('foo'));
|
|
|
|
$this->assertFalse($soapRequest->getArgument('foo', false));
|
2011-09-03 21:15:51 +02:00
|
|
|
|
|
|
|
$soapRequest->addArgument('foo', 'bar');
|
|
|
|
|
|
|
|
$this->assertEquals('bar', $soapRequest->getArgument('foo', false));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetOptions()
|
|
|
|
{
|
|
|
|
$soapRequest = new SoapRequest();
|
|
|
|
$options = array(
|
|
|
|
'uri' => 'foo',
|
|
|
|
'soapaction' => 'bar',
|
|
|
|
);
|
|
|
|
$soapRequest->setOptions($options);
|
|
|
|
|
|
|
|
$this->assertEquals($options, $soapRequest->getOptions());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetOption()
|
|
|
|
{
|
|
|
|
$soapRequest = new SoapRequest();
|
|
|
|
|
2011-09-04 23:42:03 +02:00
|
|
|
$this->assertSame(null, $soapRequest->getOption('soapaction'));
|
|
|
|
$this->assertFalse($soapRequest->getOption('soapaction', false));
|
2011-09-03 21:15:51 +02:00
|
|
|
|
|
|
|
$soapRequest->addOption('soapaction', 'foo');
|
|
|
|
|
|
|
|
$this->assertEquals('foo', $soapRequest->getOption('soapaction'));
|
|
|
|
}
|
|
|
|
|
2011-09-04 23:42:03 +02:00
|
|
|
public function testSetHeaders()
|
|
|
|
{
|
|
|
|
$soapRequest = new SoapRequest();
|
|
|
|
|
2011-09-23 10:23:59 +02:00
|
|
|
$this->assertEquals(null, $soapRequest->getHeaders());
|
2011-09-04 23:42:03 +02:00
|
|
|
|
|
|
|
$header1 = new \SoapHeader('foobar', 'foo', 'bar');
|
|
|
|
$header2 = new \SoapHeader('barfoo', 'bar', 'foo');
|
|
|
|
$soapRequest
|
|
|
|
->addHeader($header1)
|
|
|
|
->addHeader($header2)
|
|
|
|
;
|
|
|
|
|
|
|
|
$this->assertSame(array($header1, $header2), $soapRequest->getHeaders());
|
|
|
|
}
|
|
|
|
|
2011-09-03 21:15:51 +02:00
|
|
|
public function testConstruct()
|
|
|
|
{
|
|
|
|
$soapRequest = new SoapRequest();
|
|
|
|
|
|
|
|
$this->assertNull($soapRequest->getFunction());
|
|
|
|
$this->assertEquals(array(), $soapRequest->getArguments());
|
|
|
|
$this->assertEquals(array(), $soapRequest->getOptions());
|
2011-09-23 10:23:59 +02:00
|
|
|
$this->assertEquals(null, $soapRequest->getHeaders());
|
2011-09-03 21:15:51 +02:00
|
|
|
|
|
|
|
$arguments = array('bar' => 'foobar');
|
|
|
|
$options = array('soapaction' => 'foobar');
|
2011-09-04 23:42:03 +02:00
|
|
|
$headers = array(
|
|
|
|
new \SoapHeader('foobar', 'foo', 'bar'),
|
|
|
|
new \SoapHeader('barfoo', 'bar', 'foo'),
|
|
|
|
);
|
|
|
|
$soapRequest = new SoapRequest('foo', $arguments, $options, $headers);
|
2011-09-03 21:15:51 +02:00
|
|
|
|
|
|
|
$this->assertEquals('foo', $soapRequest->getFunction());
|
|
|
|
$this->assertEquals($arguments, $soapRequest->getArguments());
|
|
|
|
$this->assertEquals($options, $soapRequest->getOptions());
|
2011-09-04 23:42:03 +02:00
|
|
|
$this->assertSame($headers, $soapRequest->getHeaders());
|
2011-09-03 21:15:51 +02:00
|
|
|
}
|
2011-09-23 10:23:59 +02:00
|
|
|
}
|