2010-10-08 17:27:46 +02:00
|
|
|
<?php
|
|
|
|
/*
|
2011-07-18 22:43:12 +02:00
|
|
|
* This file is part of the BeSimpleSoapBundle.
|
2010-10-08 17:27:46 +02:00
|
|
|
*
|
|
|
|
* (c) Christian Kerl <christian-kerl@web.de>
|
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
namespace BeSimple\SoapBundle\Tests\Soap;
|
2010-10-08 17:27:46 +02:00
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
use BeSimple\SoapBundle\Soap\SoapRequest;
|
2010-10-08 17:27:46 +02:00
|
|
|
|
|
|
|
/**
|
2011-07-18 22:43:12 +02:00
|
|
|
* UnitTest for \BeSimple\SoapBundle\Soap\SoapRequest.
|
2010-10-08 17:27:46 +02:00
|
|
|
*
|
|
|
|
* @author Christian Kerl <christian-kerl@web.de>
|
|
|
|
*/
|
|
|
|
class SoapRequestTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
public function testMtomMessage()
|
|
|
|
{
|
|
|
|
$content = $this->loadRequestContentFixture('mtom/simple.txt');
|
|
|
|
|
2011-07-14 16:46:28 +02:00
|
|
|
$request = new SoapRequest(array(), array(), array(), array(), array(), array(), $content);
|
2010-10-08 17:27:46 +02:00
|
|
|
$request->server->set('CONTENT_TYPE', 'multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:0ca0e16e-feb1-426c-97d8-c4508ada5e82+id=7";start-info="application/soap+xml"');
|
|
|
|
|
|
|
|
$message = $request->getSoapMessage();
|
|
|
|
|
|
|
|
$this->assertEquals(735, strlen(trim($message)));
|
|
|
|
$this->assertEquals(1, count($request->getSoapAttachments()));
|
|
|
|
|
|
|
|
$attachment = $request->getSoapAttachments()->get('http://tempuri.org/1/632618206527087310');
|
|
|
|
|
|
|
|
$this->assertNotNull($attachment);
|
|
|
|
$this->assertEquals('application/octet-stream', $attachment->getType());
|
|
|
|
$this->assertEquals(767, strlen(trim($attachment->getContent())));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function loadRequestContentFixture($name)
|
|
|
|
{
|
2011-07-17 10:46:54 +02:00
|
|
|
return file_get_contents(__DIR__.'/../Fixtures/Soap/'.$name);
|
2010-10-08 17:27:46 +02:00
|
|
|
}
|
|
|
|
}
|