forked from lsmonki/php-ixr
-
Notifications
You must be signed in to change notification settings - Fork 6
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 #5 from dokudeps/master
Adding tests and porting over a few fixes from DokuWiki
- Loading branch information
Showing
7 changed files
with
204 additions
and
25 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.project | ||
.idea | ||
.vscode | ||
.phpunit.result.cache | ||
composer.lock | ||
vendor |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
|
||
<testsuites> | ||
<testsuite name="all"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src/</directory> | ||
</whitelist> | ||
</filter> | ||
</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
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,53 @@ | ||
<?php | ||
|
||
namespace IXR\tests\DataType; | ||
|
||
use IXR\DataType\Date; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class DateTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @return array | ||
* @see testParseIso | ||
*/ | ||
function provideDates() | ||
{ | ||
return [ | ||
// full datetime, different formats | ||
['2010-08-17T09:23:14', 1282036994], | ||
['20100817T09:23:14', 1282036994], | ||
['2010-08-17 09:23:14', 1282036994], | ||
['20100817 09:23:14', 1282036994], | ||
['2010-08-17T09:23:14Z', 1282036994], | ||
['20100817T09:23:14Z', 1282036994], | ||
|
||
// with timezone | ||
['2010-08-17 09:23:14+0000', 1282036994], | ||
['2010-08-17 09:23:14+00:00', 1282036994], | ||
['2010-08-17 12:23:14+03:00', 1282036994], | ||
|
||
// no seconds | ||
['2010-08-17T09:23', 1282036980], | ||
['20100817T09:23', 1282036980], | ||
|
||
// no time | ||
['2010-08-17', 1282003200], | ||
[1282036980, 1282036980], | ||
// array('20100817', 1282003200), #this will NOT be parsed, but is assumed to be timestamp | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideDates | ||
* @param mixed $input | ||
* @param int $expect | ||
*/ | ||
function testParseIso($input, $expect) | ||
{ | ||
$dt = new Date($input); | ||
$this->assertEquals($expect, $dt->getTimeStamp()); | ||
} | ||
|
||
} |
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,110 @@ | ||
<?php | ||
|
||
namespace IXR\tests\Message; | ||
|
||
use IXR\Message\Message; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ixr_library_ixr_message_test extends TestCase | ||
{ | ||
|
||
function testUntypedValue() | ||
{ | ||
$xml = '<?xml version="1.0" encoding="UTF-8"?> | ||
<methodCall> | ||
<methodName>wiki.getBackLinks</methodName> | ||
<params> | ||
<param> | ||
<value> change </value> | ||
</param> | ||
</params> | ||
</methodCall>'; | ||
|
||
$ixrmsg = new Message($xml); | ||
$ixrmsg->parse(); | ||
|
||
$this->assertEquals($ixrmsg->messageType, 'methodCall'); | ||
$this->assertEquals($ixrmsg->methodName, 'wiki.getBackLinks'); | ||
$this->assertEquals($ixrmsg->params, [' change ']); | ||
} | ||
|
||
function testStringValue() | ||
{ | ||
$xml = '<?xml version="1.0" encoding="UTF-8"?> | ||
<methodCall> | ||
<methodName>wiki.getBackLinks</methodName> | ||
<params> | ||
<param> | ||
<value> | ||
<string> change </string> | ||
</value> | ||
</param> | ||
</params> | ||
</methodCall>'; | ||
|
||
$ixrmsg = new Message($xml); | ||
$ixrmsg->parse(); | ||
|
||
$this->assertEquals($ixrmsg->messageType, 'methodCall'); | ||
$this->assertEquals($ixrmsg->methodName, 'wiki.getBackLinks'); | ||
$this->assertEquals($ixrmsg->params, [' change ']); | ||
} | ||
|
||
function testEmptyValue() | ||
{ | ||
$xml = '<?xml version="1.0" encoding="UTF-8"?> | ||
<methodCall> | ||
<methodName>wiki.getBackLinks</methodName> | ||
<params> | ||
<param> | ||
<value> | ||
<string></string> | ||
</value> | ||
</param> | ||
</params> | ||
</methodCall>'; | ||
|
||
$ixrmsg = new Message($xml); | ||
$ixrmsg->parse(); | ||
|
||
$this->assertEquals($ixrmsg->messageType, 'methodCall'); | ||
$this->assertEquals($ixrmsg->methodName, 'wiki.getBackLinks'); | ||
$this->assertEquals($ixrmsg->params, ['']); | ||
} | ||
|
||
function testStruct() | ||
{ | ||
$xml = '<?xml version=\'1.0\'?> | ||
<methodCall> | ||
<methodName>wiki.putPage</methodName> | ||
<params> | ||
<param> | ||
<value><string>start</string></value> | ||
</param> | ||
<param> | ||
<value><string>test text </string></value> | ||
</param> | ||
<param> | ||
<value><struct> | ||
<member> | ||
<name>sum</name> | ||
<value><string>xmlrpc edit</string></value> | ||
</member> | ||
<member> | ||
<name>minor</name> | ||
<value><string>1</string></value> | ||
</member> | ||
</struct></value> | ||
</param> | ||
</params> | ||
</methodCall>'; | ||
|
||
$ixrmsg = new Message($xml); | ||
$ixrmsg->parse(); | ||
|
||
$this->assertEquals($ixrmsg->messageType, 'methodCall'); | ||
$this->assertEquals($ixrmsg->methodName, 'wiki.putPage'); | ||
$this->assertEquals($ixrmsg->params, ['start', 'test text ', ['sum' => 'xmlrpc edit', 'minor' => '1']]); | ||
} | ||
|
||
} |