Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow Symfony2.4+ #12

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
vendor
/phpunit.xml
.buildpath
.project
.settings
vendor/
composer.lock
phpunit.xml
Tests/Fixtures/build_include/
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
56 changes: 56 additions & 0 deletions Tests/AbstractWebserverTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/*
* This file is part of the BeSimpleSoapClient.
*
* (c) Christian Kerl <[email protected]>
* (c) Francis Besset <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace BeSimple\SoapClient\Tests;

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

/**
* @author [email protected] <[email protected]>
*/
abstract class AbstractWebServerTest extends \PHPUnit_Framework_TestCase
{
/**
* @var ProcessBuilder
*/
static protected $webserver;
static protected $websererPortLength;

public static function setUpBeforeClass()
{
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)
$phpFinder->find(),
'-S',
sprintf('localhost:%d', WEBSERVER_PORT),
'-t',
__DIR__.DIRECTORY_SEPARATOR.'Fixtures',
))->getProcess();

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

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

public static function tearDownAfterClass()
{
self::$webserver->stop(0);
usleep(100000);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
107 changes: 107 additions & 0 deletions Tests/CurlTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

/*
* This file is part of the BeSimpleSoapClient.
*
* (c) Christian Kerl <[email protected]>
* (c) Francis Besset <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace BeSimple\SoapClient\Tests;

use BeSimple\SoapClient\Curl;

/**
* @author Andreas Schamberger <[email protected]>
*/
class CurlTest extends AbstractWebserverTest
{
public function testExec()
{
$curl = new Curl();

$this->assertTrue($curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)));
$this->assertTrue($curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT)));
}

public function testGetErrorMessage()
{
$curl = new Curl();

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

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

$curl->exec('');
$this->assertEquals('Unable to parse URL', $curl->getErrorMessage());
}

public function testGetRequestHeaders()
{
$curl = new Curl();

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

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

public function testGetResponse()
{
$curl = new Curl();

$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
$this->assertSame('OK', $curl->getResponseStatusMessage());
$this->assertEquals(145 + self::$websererPortLength, strlen($curl->getResponse()));

$curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT));
$this->assertSame('Not Found', $curl->getResponseStatusMessage());
}

public function testGetResponseBody()
{
$curl = new Curl();

$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
$this->assertEquals('This is a testfile for cURL.', $curl->getResponseBody());
}

public function testGetResponseContentType()
{
$curl = new Curl();

$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
$this->assertEquals('text/plain; charset=UTF-8', $curl->getResponseContentType());

$curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT));
$this->assertEquals('text/html; charset=UTF-8', $curl->getResponseContentType());
}

public function testGetResponseHeaders()
{
$curl = new Curl();

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

$curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT));
$this->assertEquals(124 + self::$websererPortLength, strlen($curl->getResponseHeaders()));
}

public function testGetResponseStatusCode()
{
$curl = new Curl();

$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
$this->assertEquals(200, $curl->getResponseStatusCode());

$curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT));
$this->assertEquals(404, $curl->getResponseStatusCode());
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<wsdl:documentation>wsdlincludetest</wsdl:documentation>
<wsdl:include location="http://localhost:8000/wsdl_include.wsdl"/>
<wsdl:include location="http://%location%/wsdl_include.wsdl"/>
</wsdl:definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<wsdl:documentation>xsdinctest</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test.sample">
<xs:include schemaLocation="http://localhost:8000/type_include.xsd"/>
<xs:include schemaLocation="http://%location%/type_include.xsd"/>
</xs:schema>
</wsdl:types>
</wsdl:definitions>
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* with this source code in the file LICENSE.
*/

namespace BeSimple\Tests\SoapCommon\Soap;
namespace BeSimple\SoapClient\Tests;

use BeSimple\SoapClient\SoapClientBuilder;

Expand Down Expand Up @@ -116,4 +116,4 @@ private function mergeOptions(array $options)
{
return array_merge($this->defaultOptions, $options);
}
}
}
Loading