-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from abimus/fix/flags
Fix behavior on Server::setFlag()
- Loading branch information
Showing
3 changed files
with
70 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="tests/bootstrap.php" | ||
> | ||
|
||
<testsuites> | ||
<testsuite name="Fetch Test Suite"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,47 @@ | |
|
||
namespace Fetch\Test; | ||
|
||
use Fetch\Server; | ||
|
||
/** | ||
* @package Fetch | ||
* @author Robert Hafner <[email protected]> | ||
*/ | ||
class ServerTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
/** | ||
* @dataProvider flagsDataProvider | ||
* @param string $expected server string with %host% placeholder | ||
* @param integer $port to use (needed to test behavior on port 143 and 993 from constructor) | ||
* @param array $flags to set/unset ($flag => $value) | ||
*/ | ||
public function testFlags($expected, $port, $flags) | ||
{ | ||
$host = 'example.com'; | ||
$server = new Server($host, $port); | ||
|
||
foreach ($flags as $flag => $value) { | ||
$server->setFlag($flag, $value); | ||
} | ||
|
||
$this->assertEquals(str_replace('%host%', $host, $expected), $server->getServerString()); | ||
} | ||
|
||
public function flagsDataProvider() { | ||
return array( | ||
array('{%host%:143/novalidate-cert}', 143, array()), | ||
array('{%host%:143/validate-cert}', 143, array('validate-cert' => true)), | ||
array('{%host%:143}', 143, array('novalidate-cert' => false)), | ||
array('{%host%:993/ssl}', 993, array()), | ||
array('{%host%:993}', 993, array('ssl' => false)), | ||
array('{%host%:100/tls}', 100, array('tls' => true)), | ||
array('{%host%:100/tls}', 100, array('tls' => true, 'tls' => true)), | ||
array('{%host%:100/notls}', 100, array('tls' => true, 'notls' => true)), | ||
array('{%host%:100}', 100, array('ssl' => true, 'ssl' => false)), | ||
array('{%host%:100/user=foo}', 100, array('user' => 'foo')), | ||
array('{%host%:100/user=foo}', 100, array('user' => 'foo', 'user' => 'foo')), | ||
array('{%host%:100/user=bar}', 100, array('user' => 'foo', 'user' => 'bar')), | ||
array('{%host%:100}', 100, array('user' => 'foo', 'user' => false)), | ||
); | ||
} | ||
} |