mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-27 23:29:57 +09:00
17515512: JanRain php-openid library included, normalization fix
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5137 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
f541dd59b9
commit
658c0e6dbc
219 changed files with 41415 additions and 10 deletions
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Tests for the Yadis HTML parsing functionality.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: See the COPYING file included in this distribution.
|
||||
*
|
||||
* @package Yadis
|
||||
* @author JanRain, Inc. <openid@janrain.com>
|
||||
* @copyright 2005 Janrain, Inc.
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
*/
|
||||
|
||||
require_once 'Tests/Services/Yadis/TestUtil.php';
|
||||
require_once 'Services/Yadis/ParseHTML.php';
|
||||
require_once 'PHPUnit.php';
|
||||
|
||||
class Tests_Services_Yadis_ParseTest extends PHPUnit_TestCase {
|
||||
function Tests_Services_Yadis_ParseTest($case)
|
||||
{
|
||||
list($result, $comment, $html) = $case;
|
||||
|
||||
$this->result = $result;
|
||||
$this->comment = $comment;
|
||||
$this->html_string = $html;
|
||||
$this->parser = new Services_Yadis_ParseHTML();
|
||||
}
|
||||
|
||||
function getName()
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
function runTest()
|
||||
{
|
||||
$value = $this->parser->getHTTPEquiv($this->html_string);
|
||||
|
||||
if ($this->result == "EOF") {
|
||||
$this->assertTrue($value === null);
|
||||
} else if ($this->result == "None") {
|
||||
$this->assertTrue($value === null);
|
||||
} else {
|
||||
$this->assertEquals($this->result, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Tests_Services_Yadis_ParseHTML extends PHPUnit_TestSuite {
|
||||
|
||||
function getName()
|
||||
{
|
||||
return "Tests_Services_Yadis_Parse";
|
||||
}
|
||||
|
||||
function parseTests($s)
|
||||
{
|
||||
$tests = array();
|
||||
|
||||
$cases = preg_split("/\f\n/", $s);
|
||||
|
||||
foreach ($cases as $case) {
|
||||
// Split the case text on newline, and keep the first two
|
||||
// lines and re-join the rest (those are the HTML).
|
||||
$parts = explode("\n", $case);
|
||||
$result = $parts[0];
|
||||
$html_comment = $parts[1];
|
||||
$html_string = implode("\n", array_slice($parts, 2));
|
||||
$tests[] = array($result, $html_comment, $html_string);
|
||||
}
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
function Tests_Services_Yadis_ParseHTML()
|
||||
{
|
||||
$test_data = Tests_Services_Yadis_readdata('test1-parsehtml.txt');
|
||||
|
||||
$test_cases = $this->parseTests($test_data);
|
||||
|
||||
foreach ($test_cases as $case) {
|
||||
$this->addTest(new Tests_Services_Yadis_ParseTest($case));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue