Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
language: php
os:
- linux
dist: bionic

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0
- 8.1.0

env:
- SYMFONY_VERSION=2.7.*
- SYMFONY_VERSION=2.8.*
- SYMFONY_VERSION=3.4.*
- SYMFONY_VERSION=5.4.*
- SYMFONY_VERSION=6.0.*

matrix:
allow_failures:
- php: 5.6
- php: 7.1
jobs:
exclude:
- php: 7.4
env: SYMFONY_VERSION=6.0.*

before_script:
- phpenv config-add myphp.ini
Expand All @@ -27,7 +26,7 @@ before_script:
- ./src/BeSimple/SoapClient/Tests/bin/axis.sh

script:
- bin/simple-phpunit --coverage-text --debug
- SYMFONY_DEPRECATIONS_HELPER="max[indirect]=6" bin/simple-phpunit --coverage-text

notifications:
email:
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
}
],
"require": {
"php": ">=5.4.0",
"php": ">=7.4.0",
"ext-soap": "*",
"ext-curl": "*",
"ass/xmlsecurity": "~1.0",
"symfony/framework-bundle": "~2.6 || ~3.4",
"symfony/twig-bundle": "~2.6 || ~3.4",
"zendframework/zend-mime": "2.*",
"zendframework/zend-serializer": "^2.9",
"zendframework/zend-servicemanager": "^3.3"
"symfony/error-handler": "^5.4.3 || ^6.0.3",
"symfony/framework-bundle": "^5.4.4 || ^6.0.4",
"laminas/laminas-mail": "2.*",
"laminas/laminas-mime": "2.*",
"laminas/laminas-serializer": "^2.12"
},
"replace": {
"besimple/soap-bundle": "self.version",
Expand All @@ -39,8 +39,8 @@
},
"require-dev": {
"mikey179/vfsstream": "~1.0",
"symfony/filesystem": "~2.3",
"symfony/process": "~2.3",
"symfony/filesystem": "^5.4.3 || ^6.0.3",
"symfony/process": "^5.4.3 || ^6.0.3",
"symfony/phpunit-bridge": "*"
},
"autoload": {
Expand All @@ -54,4 +54,4 @@
"config": {
"bin-dir": "bin"
}
}
}
2 changes: 1 addition & 1 deletion src/BeSimple/SoapBundle/Soap/SoapRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
namespace BeSimple\SoapBundle\Soap;

use BeSimple\SoapBundle\Util\Collection;
use Laminas\Mime\Message;
use Symfony\Component\HttpFoundation\Request;
use Zend\Mime\Message;

/**
* SoapRequest.
Expand Down
2 changes: 0 additions & 2 deletions src/BeSimple/SoapBundle/Tests/Soap/SoapRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class SoapRequestTest extends \PHPUnit\Framework\TestCase
{
public function testMtomMessage()
{
$this->markTestSkipped('Skip because I\'m not sure that SoapRequest is used in a HTTP Request process.');

$content = $this->loadRequestContentFixture('mtom/simple.txt');

$request = new SoapRequest(array(), array(), array(), array(), array(), array(), $content);
Expand Down
4 changes: 2 additions & 2 deletions src/BeSimple/SoapBundle/Util/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ public function clear()
$this->elements = array();
}

public function count()
public function count(): int
{
return count($this->elements);
}

public function getIterator()
public function getIterator(): \Traversable
{
return new \ArrayIterator($this->elements);
}
Expand Down
2 changes: 1 addition & 1 deletion src/BeSimple/SoapBundle/WebServiceContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use BeSimple\SoapCommon\Converter\TypeConverterCollection;
use BeSimple\SoapWsdl\Dumper\Dumper;
use BeSimple\SoapServer\SoapServerBuilder;
use Laminas\Serializer\Serializer;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Loader\LoaderInterface;
use Zend\Serializer\Serializer;

/**
* WebServiceContext.
Expand Down
10 changes: 5 additions & 5 deletions src/BeSimple/SoapClient/SoapClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ protected function __doHttpRequest(SoapRequest $soapRequest)
*
* @return string
*/
public function __doRequest($request, $location, $action, $version, $oneWay = 0)
public function __doRequest($request, $location, $action, $version, $oneWay = 0): ?string
{
// wrap request data in SoapRequest object
$soapRequest = SoapRequest::create($request, $location, $action, $version);
Expand Down Expand Up @@ -307,7 +307,7 @@ protected function filterRequestOptions(SoapRequest $soapRequest)
*
* @return string
*/
public function __getLastRequestHeaders()
public function __getLastRequestHeaders(): ?string
{
return $this->lastRequestHeaders;
}
Expand All @@ -327,7 +327,7 @@ public function __getRequestHeaders()
*
* @return string
*/
public function __getLastRequest()
public function __getLastRequest(): ?string
{
return $this->lastRequest;
}
Expand All @@ -347,7 +347,7 @@ public function __getLastRequestUri()
*
* @return string
*/
public function __getLastResponseHeaders()
public function __getLastResponseHeaders(): ?string
{
return $this->lastResponseHeaders;
}
Expand All @@ -357,7 +357,7 @@ public function __getLastResponseHeaders()
*
* @return string
*/
public function __getLastResponse()
public function __getLastResponse(): ?string
{
return $this->lastResponse;
}
Expand Down
23 changes: 7 additions & 16 deletions src/BeSimple/SoapClient/Tests/AbstractWebserverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,37 @@
namespace BeSimple\SoapClient\Tests;

use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\ProcessBuilder;
use Symfony\Component\Process\Process;

/**
* @author francis.besset@gmail.com <francis.besset@gmail.com>
*/
abstract class AbstractWebServerTest extends \PHPUnit\Framework\TestCase
{
// when using the SetUpTearDownTrait, methods like doSetup() can
// be defined with and without the 'void' return type, as you wish
use \Symfony\Bridge\PhpUnit\SetUpTearDownTrait;

/**
* @var ProcessBuilder
*/
static protected $webserver;
static protected $websererPortLength;
static protected $webserverPortLength;

public static function doSetUpBeforeClass()
public static function setUpBeforeClass(): void
{
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
self::markTestSkipped('PHP Webserver is available from PHP 5.4');
}

$phpFinder = new PhpExecutableFinder();
self::$webserver = ProcessBuilder::create(array(
'exec', // used exec binary (https://github.com/symfony/symfony/issues/5759)
self::$webserver = new Process(array(
$phpFinder->find(),
'-S',
sprintf('localhost:%d', WEBSERVER_PORT),
'-t',
__DIR__.DIRECTORY_SEPARATOR.'Fixtures',
))->getProcess();
));

self::$webserver->start();
usleep(200000);

self::$websererPortLength = strlen(WEBSERVER_PORT);
self::$webserverPortLength = strlen(WEBSERVER_PORT);
}

public static function doTearDownAfterClass()
public static function tearDownAfterClass(): void
{
self::$webserver->stop(0);
usleep(100000);
Expand Down
6 changes: 1 addition & 5 deletions src/BeSimple/SoapClient/Tests/AxisInterop/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

class TestCase extends \PHPUnit\Framework\TestCase
{
// when using the SetUpTearDownTrait, methods like doSetup() can
// be defined with and without the 'void' return type, as you wish
use \Symfony\Bridge\PhpUnit\SetUpTearDownTrait;

protected function doSetUp()
protected function setUp(): void
{
$ch = curl_init('http://localhost:8080/');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
Expand Down
43 changes: 29 additions & 14 deletions src/BeSimple/SoapClient/Tests/CurlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public function testGetErrorMessage()
));

$curl->exec('http://unknown/curl.txt');
$this->assertRegExp('/^Could not connect to host.*$/', $curl->getErrorMessage());
$this->assertMatchesRegularExpression('/^Could not connect to host.*$/', $curl->getErrorMessage());

$curl->exec(sprintf('xyz://localhost:%d/@404.txt', WEBSERVER_PORT));
$this->assertRegExp('/^Unknown protocol. Only http and https are allowed.*$/', $curl->getErrorMessage());
$this->assertMatchesRegularExpression('/^Unknown protocol. Only http and https are allowed.*$/', $curl->getErrorMessage());

$curl->exec('');
$this->assertRegExp('/^Unable to parse URL.*$/', $curl->getErrorMessage());
$this->assertMatchesRegularExpression('/^Unable to parse URL.*$/', $curl->getErrorMessage());
}

public function testGetRequestHeaders()
Expand All @@ -53,10 +53,10 @@ public function testGetRequestHeaders()
));

$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
$this->assertEquals(132 + self::$websererPortLength, strlen($curl->getRequestHeaders()));
$this->assertCorrectRequestHeaders($curl->getRequestHeaders(), '/curl.txt');

$curl->exec(sprintf('http://localhost:%s/404.txt', WEBSERVER_PORT));
$this->assertEquals(131 + self::$websererPortLength, strlen($curl->getRequestHeaders()));
$this->assertCorrectRequestHeaders($curl->getRequestHeaders(), '/404.txt');
}

public function testGetResponse()
Expand All @@ -67,10 +67,11 @@ public function testGetResponse()

$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
$this->assertSame('OK', $curl->getResponseStatusMessage());
// Adjust for PHP >= 7.2 sending a Date header

$response = $curl->getResponse();
$response = preg_replace('/^Date:.*?\r\n/m', '', $response);
$this->assertEquals(145 + self::$websererPortLength, strlen($response));
[$headers, $body] = explode("\r\n\r\n", $response, 2);
$this->assertCorrectResponseHeaders($headers, '200 OK', 'text/plain', strlen($body));
$this->assertSame('This is a testfile for cURL.', $body);

$curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT));
$this->assertSame('Not Found', $curl->getResponseStatusMessage());
Expand Down Expand Up @@ -106,16 +107,12 @@ public function testGetResponseHeaders()
));

$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
// Adjust for PHP >= 7.2 sending a Date header
$headers = $curl->getResponseHeaders();
$headers = preg_replace('/^Date:.*?\r\n/m', '', $headers);
$this->assertEquals(117 + self::$websererPortLength, strlen($headers));
$this->assertCorrectResponseHeaders($headers, '200 OK', 'text/plain');

$curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT));
// Adjust for PHP >= 7.2 sending a Date header
$headers = $curl->getResponseHeaders();
$headers = preg_replace('/^Date:.*?\r\n/m', '', $headers);
$this->assertEquals(124 + self::$websererPortLength, strlen($headers));
$this->assertCorrectResponseHeaders($headers, '404 Not Found', 'text/html');
}

public function testGetResponseStatusCode()
Expand All @@ -130,4 +127,22 @@ public function testGetResponseStatusCode()
$curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT));
$this->assertEquals(404, $curl->getResponseStatusCode());
}

protected function assertCorrectRequestHeaders($headerStr, $requestPath)
{
$headers = explode("\r\n", $headerStr);
$this->assertContains("GET $requestPath HTTP/1.1", $headers);
$this->assertContains('User-Agent: PHP-SOAP/\BeSimple\SoapClient', $headers);
$this->assertContains('Accept: */*', $headers);
}

protected function assertCorrectResponseHeaders($headerStr, $status, $contentType, $contentLen = null)
{
$headers = explode("\r\n", $headerStr);
$this->assertContains("HTTP/1.1 $status", $headers);
$this->assertContains("Content-Type: $contentType; charset=UTF-8", $headers);
if (null !== $contentLen) {
$this->assertContains("Content-Length: $contentLen", $headers);
}
}
}
12 changes: 1 addition & 11 deletions src/BeSimple/SoapClient/Tests/ServerInterop/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,8 @@

class TestCase extends \PHPUnit\Framework\TestCase
{
// when using the SetUpTearDownTrait, methods like doSetup() can
// be defined with and without the 'void' return type, as you wish
use \Symfony\Bridge\PhpUnit\SetUpTearDownTrait;

protected function doSetUp()
protected function setUp(): void
{
if (version_compare(PHP_VERSION, '5.3.0', '=')) {
$this->markTestSkipped(
'The PHP cli webserver is not available with PHP 5.3.'
);
}

$ch = curl_init('http://localhost:8081/');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, true);
Expand Down
2 changes: 1 addition & 1 deletion src/BeSimple/SoapClient/Tests/SoapClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testSoapFaultWhenPassingInvalidWSDLs($wsdl)
}

$this->assertInstanceOf('SoapFault', $soapFault, 'Invalid type of exception');
$this->assertRegExp('/SOAP-ERROR: Parsing WSDL: .*/', $soapFault->getMessage(), 'Invalid or incorrect exception message');
$this->assertMatchesRegularExpression('/SOAP-ERROR: Parsing WSDL: .*/', $soapFault->getMessage(), 'Invalid or incorrect exception message');
$this->assertStringContainsString('WSDL', $soapFault->faultcode, 'Invalid type of faultcode');
}

Expand Down
Loading