Permalink
Browse files

#18106: fixed package.xml (thanks to glen)

git-svn-id: http://svn.php.net/repository/pear/packages/Net_IDNA2/trunk@306129 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
neufeind committed Dec 9, 2010
1 parent c1d5fc7 commit 68c072ef19eb673989473644ed34102f52fdb00b
Showing with 93 additions and 69 deletions.
  1. +3 −3 package.xml
  2. +30 −30 tests/AllTests.php
  3. +60 −36 tests/Net_IDNA2Test.php
View
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<package packagerversion="1.9.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>Net_IDNA2</name>
<channel>pear.php.net</channel>
<summary>Punycode encoding and decoding.</summary>
@@ -29,8 +29,8 @@
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
* Added initial support for IDNA2008. This is needed for characters like the German
"Eszett" which would otherwise be turned into "ss" during nameprep.
Use $n->setParams('version', '2008') to use the "new" IDNA-encoding. Default is still
&quot;Eszett&quot; which would otherwise be turned into &quot;ss&quot; during nameprep.
Use $n-&gt;setParams(&apos;version&apos;, &apos;2008&apos;) to use the &quot;new&quot; IDNA-encoding. Default is still
IDNA2003 for backwards-compatibility.
Further aspects of IDNA2008-encoding (for example some checks) should be added later
according to RFCs.
View
@@ -1,30 +1,30 @@
<?php
if (!defined('PHPUnit2_MAIN_METHOD')) {
define('PHPUnit2_MAIN_METHOD', 'Net_IDNA2_AllTests::main');
}
require_once 'PHPUnit2/TextUI/TestRunner.php';
require_once 'Net_IDNA2Test.php';
class Net_IDNA2_AllTests
{
public static function main()
{
PHPUnit2_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new PHPUnit2_Framework_TestSuite('PEAR - Net_IDNA2');
$suite->addTestSuite('Net_IDNA2Test');
return $suite;
}
}
if (PHPUnit2_MAIN_METHOD == 'Net_IDNA2_AllTests::main') {
Net_IDNA2_AllTests::main();
}
<?php
if (!defined('PHPUnit2_MAIN_METHOD')) {
define('PHPUnit2_MAIN_METHOD', 'Net_IDNA2_AllTests::main');
}
require_once 'PHPUnit2/TextUI/TestRunner.php';
require_once 'Net_IDNA2Test.php';
class Net_IDNA2_AllTests
{
public static function main()
{
PHPUnit2_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new PHPUnit2_Framework_TestSuite('PEAR - Net_IDNA2');
$suite->addTestSuite('Net_IDNA2Test');
return $suite;
}
}
if (PHPUnit2_MAIN_METHOD == 'Net_IDNA2_AllTests::main') {
Net_IDNA2_AllTests::main();
}
View
@@ -1,36 +1,60 @@
<?php
require_once 'Net/IDNA2.php';
require_once 'PHPUnit2/Framework/TestCase.php';
class Net_IDNA2Test extends PHPUnit2_Framework_TestCase {
public function setUp() {
$this->idn = new Net_IDNA2();
}
public function testShouldDecodePortNumbersFragmentsAndUrisCorrectly() {
// not sure where this testcase came from, but it's wrong
// $result = $this->idn->decode('http://www.xn--ml-6kctd8d6a.org:8080/test.php?arg1=1&arg2=2#fragment');
// $this->assertSame("http://www.ехаmрlе.org:8080/test.php?arg=1#fragment", $result);
$result = $this->idn->decode('http://xn--tst-qla.example.com:8080/test.php?arg1=1&arg2=2#fragment');
$this->assertSame("http://täst.example.com:8080/test.php?arg1=1&arg2=2#fragment", $result);
}
public function testEncodingForGermanEszettUsingIDNA2003() {
// make sure to use 2003-encoding
$this->idn->setParams('version', '2003');
$result = $this->idn->encode('http://www.straße.example.com/');
$this->assertSame("http://www.strasse.example.com/", $result);
}
public function testEncodingForGermanEszettUsingIDNA2008() {
// make sure to use 2008-encoding
$this->idn->setParams('version', '2008');
$result = $this->idn->encode('http://www.straße.example.com/');
// switch back for other testcases
$this->idn->setParams('version', '2003');
$this->assertSame("http://www.xn--strae-oqa.example.com/", $result);
}
}
<?php
require_once 'Net/IDNA2.php';
require_once 'PHPUnit2/Framework/TestCase.php';
class Net_IDNA2Test extends PHPUnit2_Framework_TestCase
{
/**
* Initialise tests
*
* @return void
*/
public function setUp()
{
$this->idn = new Net_IDNA2();
}
/**
* Test if a complete URL consisting also of port-number etc. will be decoded just fine
*
* @return void
*/
public function testShouldDecodePortNumbersFragmentsAndUrisCorrectly()
{
// not sure where this testcase came from, but it's wrong
// $result = $this->idn->decode('http://www.xn--ml-6kctd8d6a.org:8080/test.php?arg1=1&arg2=2#fragment');
// $this->assertSame("http://www.ехаmрlе.org:8080/test.php?arg=1#fragment", $result);
$result = $this->idn->decode('http://xn--tst-qla.example.com:8080/test.php?arg1=1&arg2=2#fragment');
$this->assertSame("http://täst.example.com:8080/test.php?arg1=1&arg2=2#fragment", $result);
}
/**
* Test encoding of German letter Eszett according to the original standard (IDNA2003)
*
* @return void
*/
public function testEncodingForGermanEszettUsingIDNA2003()
{
// make sure to use 2003-encoding
$this->idn->setParams('version', '2003');
$result = $this->idn->encode('http://www.straße.example.com/');
$this->assertSame("http://www.strasse.example.com/", $result);
}
/**
* Test encoding of German letter Eszett according to the "new" standard (IDNA2005/IDNAbis)
*
* @return void
*/
public function testEncodingForGermanEszettUsingIDNA2008()
{
// make sure to use 2008-encoding
$this->idn->setParams('version', '2008');
$result = $this->idn->encode('http://www.straße.example.com/');
// switch back for other testcases
$this->idn->setParams('version', '2003');
$this->assertSame("http://www.xn--strae-oqa.example.com/", $result);
}
}

0 comments on commit 68c072e

Please sign in to comment.